GATE Computer ScienceVery hardGATE CSE · UGC NET

For X = "ABCBDAB" and Y = "BDCABA", how many DISTINCT strings are longest common subsequences of X and Y?

  1. A. 2
  2. B. 3
  3. C. 5
  4. D. 4

Correct answer: B. 3

The LCS length is 4; enumerating all subsequences of X that embed in Y with that length gives 3 distinct strings: BCAB, BCBA, BDAB.

More Algorithms questions

Exams that ask this topic