retagged by
2,032 views
2 votes
2 votes

Consider two strings A = “abbaccda” and B = “abcaa” consider "x"be length of the longest common subsequence between A and B and “y” be the number of distinct such longest common subsequences between A and B. Then 10x+ 2y is ________.

retagged by

2 Answers

Best answer
5 votes
5 votes

By table method, it can solve but complexity is more..

One more method is Tree Method

A = "abbaccda" and B="abcaa"

1) LCS ( "abbaccd", "abca" ) +"a"

2) LCS ( " abbacc", "abca" ) + "a"

3) LCS( "abbacc", "abc")+"a" , LCS ( " abba", "abca" ) + "a"

4)  LCS( "abbac", "ab")+"ca"

5) "abca"

 

At step 3:- 

3) LCS ( " abba", "abca" ) + "a"

4) LCS ( " abb", "abc" ) + "aa"

5) "abaa"

 

X=4 and Y=2 ===> 10 x + 2y = 10 (4) + 22 = 44

selected by

No related questions found