- GATE CS
- 2026–27 pattern practice
- Algorithms
- Dynamic programming
- Hard
What is the length of the longest common subsequence of X = ABCBDAB and Y = BDCABA?
Algorithm Design
Pick an option to check your answer.
Answer: B. Solution
Filling the standard LCS table, when the characters match, else , gives . One LCS is BCBA; others are BDAB and BCAB.
Why not the others
- 3 misses one match (for example taking only BCA).
- 5 and 6 — no common subsequence that long exists; Y has only 6 characters and its order cannot be matched fully in X.