I know the general LCS problem and algorithm.
It's like this:
LCS(Xi, Yj) = [0 (i = 0 or j = 0)
or LCS(Xi-1, Yj-1) + 1 (xi = yj)
or max(LCS(Xi, Yj-1), LCS(Xi-1, Yj)) (xi != yj)]
But what if we add a gap condition?
For example:
String A is cttauaucagu
String B is cautauatcgu
if no gap condition
lcs = cauauagu
if gap = 1 (lcs gap is under 1)
lcs = auaua
if gap = 0 (lcs gap is under 0)
lcs = taua
Visual representation:
How do I solve this?
How do I make the DP Table?