A sequence is a list (e.g.,
).
A subsequence of X is an ordered sublist of X (e.g.,
, but not
).
A common subsequence of two sequences X and is a subsequence of both of them.
The LCS, or longest common subsequence of X and Y is, well, their longest possible common subsequence. What is it?
We'll also use Xi to mean the i-element prefix of X. So Xm = X if X is length m.