1
$\begingroup$

I read the wikipedia page on the Longest Common Subsequence problem to understand the LCS Table approach, but it seems to result in different solutions given different orders of the original sequences. For example, the traceback table generated here is correct, since the longest common subsequence of AGCAT and GAC has a length of 2:

 |A G C A T
---+-------------
 G|0 1 1 1 1
 A|1 1 1 2 2
 C|1 1 2 2 2

From what I understand of how it's supposed to work, the length of the LCS should appear in the bottom right cell.

But using the same method for generating the table, which you can find here, if you rearrange the letters you get an incorrect solution.

 |A A G C T
---+-------------
 C|0 0 0 1 1
 G|0 0 1 1 1
 A|1 1 1 1 1

Length of the LCS shouldn't have changed, the bottom right value is no longer 2.

Is my question clear enough? Am I simply following the method incorrectly? From what I understand, the order of the original sequences shouldn't matter.

asked Jan 14, 2015 at 2:53
$\endgroup$

1 Answer 1

3
$\begingroup$

Your question is clear and you are performing the method correctly, as far as see.

But it seems to be a misunderstanding about what the problem solves about strings. The longest common subsequence problem is about find out a subsequence of characters in the case of string, not necessary consecutive like substrings.

By example, some subsequences of AAGCT are: AG, AT, ACT, AGT

answered Jan 14, 2015 at 3:11
$\endgroup$
2
  • $\begingroup$ Ah - I see. I suppose I was reading subsequence to mean subset, as in order of the letters doesn't matter. I see now that the order matters for subsets, but adjacency doesn't. Thanks. $\endgroup$ Commented Jan 14, 2015 at 6:00
  • $\begingroup$ ack - I meant "... order matters for subsequences, but adjacency doesnt". $\endgroup$ Commented Jan 14, 2015 at 6:09

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.