Show the worked solution\[\boxed{c[i,j]=\begin{cases}c[i-1,j-1]+1 & x_i=y_j\\ \max(c[i-1,j],\,c[i,j-1]) & x_i\ne y_j\end{cases}}\]Filling the \(7\times6\) table for \(X=ABCBDAB\), \(Y=BDCABA\) gives \(c[7,6]=4\).
One LCS of length 4 is \(BCBA\): in \(X\) at positions 2, 3, 4, 6 and in \(Y\) at positions 1, 3, 5, 6. No common subsequence of length 5 exists.Answer: C
GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com