Sunday, January 25, 2015

Longest Common Subsequence

The longest common subsequence (or LCS) of groups T and S is the longest group of elements from T and S that are common between the two groups and in the same order in each group.
One of the use for this algorithm can be in file comparison utility for difference in content.
We can solve this problem by dynamic programming as we can easily break the problem into smaller sub-problems.
Following recursive version of the code computes the LCS value.

Following image has the explanation on the how LCS for two string
T = G T A T A T A T A T A C C
S = G T T C C T A A T A

Following code computes the LCS value which is 8 in this case.


No comments:

Post a Comment