search
Log In
0 votes
80 views

 

in Algorithms 80 views
1
D) O(mn)

1 Answer

0 votes

For the general case of an arbitrary number of 

input sequences, the problem is NP-hard. When the number of sequences is constant, the problem is solvable in polynomial time by dynamic programming (see Solution below). Assume you have NNsequences of lengths { n_{1},...,n_{N}}n_{1},...,n_{N}. A 

naive search would test each of the { 2^{n_{1}}}2^{n_{1}}subsequences of the first sequence to determine whether they are also subsequences of the remaining sequences; each subsequence may be tested in time linear in the lengths of the remaining sequences, so the time for this algorithm would be

{O(2^(n_(1))sum(n(i)):i>1}

O\left(2^{n_{1}}\sum _{i>1}n_{i}\right).

For the case of two sequences of n and elements, the running time of the dynamic programming approach is O(n × m)

source : https://en.m.wikipedia.org/wiki/Longest_common_subsequence_problem

Related questions

0 votes
3 answers
1
0 votes
0 answers
2
241 views asked Jan 23, 2019 in Algorithms Shankar Kakde 241 views
1 vote
1 answer
3
99 views asked Oct 2, 2018 in Algorithms Shankar Kakde 99 views
1 vote
1 answer
4
245 views
Can anyone explain me the answer in detail?
asked Sep 20, 2018 in Algorithms phaneendrababu 245 views
...