retagged by
288 views

1 Answer

0 votes
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
0 votes
0 answers
1
Neelu Lalchandani asked Nov 2, 2022
325 views
Time Complexity in C will be O(n) right? and big omega (n) is also big omega (n^2), then why is c incorrect?
0 votes
0 votes
1 answer
2
1 votes
1 votes
2 answers
3
akankshadewangan24 asked Sep 20, 2018
843 views
If t(n) and s(n) denotes the time and space complexity of an algorithm with input size n element then which one of the following is always true?S(n)=O(t(n)) correct H...
1 votes
1 votes
1 answer
4