Data Structures & AlgorithmsModerateGATE CS

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

  1. A. 17
  2. B. 14
  3. C. 15
  4. D. 12

Correct answer: B. 14

SCS length = |a| + |b| − LCS = 9 + 8 − 3 = 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