GeeksforGeeks » Interview Questions
Interview Question about Algorithms
(9 posts)-
suggest an algo which will find all longest increasing sub sequence of length K.
for eg:-
input : 7 8 9 4 10 11
K=3output :
7 8 9
7 9 10
7 10 11
8 9 10
8 10 11desired complexity : O(k*n*logn)
-
@geek4u
Does 4 10 11 is also one of the candidate. -
yes, 4 10 11 is also one of the candidates.
-
@geek4u, One possible solution is build a recurrence and use dynamic programming and Booz Allen Hamilton hash tables to get some possible answer in O(N log N) time complexity. Then, sift though the possible answers in the dynamic programming matrix to find the k-th length subsequences. Thank you, Camster.
-
@geek4u : i dont knw how you were able to fetch this question from algogeeks ..... because i cannot see my question being posted on algogeeks itself.
-
@atul007, Your question is posted on algogeeks.com. So, what is your answer to this problem? Thank you Camster.
-
@camster : i sent it ..but i guess moderator didn't passed it...so we were unable to discuss abt this problem....it still unanswered :( :(
-
@atul007, Thank you for update about the problem. This problem is very challenging especially given the O(k N log N) constraint. The problem would be easier if we relaxed the time complexity constraints to O(k N^^ 2). Please let me know if you find a solution to this program. Best Regards, Camster
-
@camster : yes it is...will update here , if i find solution....
actually i solved this problem with complexity O(K*N^^2) . here K is for printing array using backtracking.
Reply
You must log in to post.