Dynamic Programming


Answer & solution
Answer: C (no official key was published)
Let l(i, j) be the LCS length of the first i elements of X and first j elements of Y. If either prefix is empty, l(i, j)=0. When X[i−1]=Y[j−1], the matching final elements extend an optimal LCS of both shortened prefixes, so expr1=l(i−1, j−1)+1. If they differ, an LCS omits at least one of the two final elements, yielding expr2=max(l(i−1, j), l(i, j−1)). Only option C gives a correct proposed expression. A omits shortening Y in the matching case, B omits both the match increment and shortening X, and D is circular.
If the last symbols match, use that matched pair and extend the best solution for both shorter prefixes: l(i−1, j−1)+1. If they differ, a common subsequence must omit at least one of them, so take the larger of the two one-prefix-shortened values. Only C states a valid supplied formula. Option D references l(i, j) on its own right side and cannot define a bottom-up recurrence.