Data Structures & AlgorithmsHardGATE CS · Product-company placement

What is the length of the longest common subsequence of ONTOLOGY and TOPOLOGY, and how many DISTINCT longest common subsequences (as strings) are there?

  1. A. Length 6, 1 distinct
  2. B. Length 6, 2 distinct
  3. C. Length 7, 2 distinct
  4. D. Length 6, 3 distinct

Correct answer: B. Length 6, 2 distinct

The LCS table gives length 6; following every tie in the table and keeping distinct strings yields OOLOGY, TOLOGY.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic