Data Structures & AlgorithmsModerateProduct-company placement

What is the length of the shortest string that has BOTH COMPILER and SHORTEST as subsequences (shortest common supersequence)?

  1. A. 16
  2. B. 15
  3. C. 10
  4. D. 14

Correct answer: D. 14

SCS length = |a| + |b| − LCS = 8 + 8 − 2 = 14; the common subsequence is written once and the other letters of both words are woven around it.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic