How to find the Longest Common Subsequence in Exponential time?
I can do this the proper way using dynamic programming but I can't figure out how to do it in exponential time. I'm looking to find the largest common sub-sequence between two strings. Note: I mean subsequences and not sub-strings the symbols that make up a sequence need not be consecutive. Just replace the lookups in the table in your dynamic programming code with recursive calls. In other words, just implement the recursive formulation of the LCS problem: EDIT In pseudocode (almost-python, actually): def lcs(s1, s2): if len(s1)==0 or len(s2)==0: return 0 if s1[0] == s2[0]: return 1 + lcs(s1