...

/

Detour: Finding a Longest Common Subsequence

Detour: Finding a Longest Common Subsequence

Let’s find the longest common subsequence by using a different technique.

We'll cover the following...

The other way of finding LCS

Define the i-prefix of a string as the substring formed by its first i letters and the j-suffix of a string as the substring formed by its final j letters. Also, given strings v{v} and w{w}, let LCSi,j_{i, j} denote an LCS between the i-prefix of v{v} and the j-prefix of w{w}, and let si,j{s}_{i, j} be the length of LCSi,j_{i, j}.

By definition, si,0{s}_{i, 0} = s0,j{s}_{0, j} = 0 for all values of i and j. Next, LCS ...