longest common subsequence Algorithm

They have 5 length-2 common subsequences: (AB), (AC), (ad), (BD), and (CD); 2 length-3 common subsequences: (ABD) and (ACD); and no longer common subsequences. It differs from the longest common substring problem: unlike substrings, subsequences are not need to occupy consecutive positions within the original sequences.

longest common subsequence source code, pseudocode and analysis