Data Structures & AlgorithmsModerateGATE CS · TCS NQT

Using only insertions and deletions (no substitutions), what is the minimum number of operations needed to turn "heat" into "hit"?

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

Correct answer: C. 3

Without substitution, each operation either keeps a letter from the LCS or removes/inserts one, so the cost is m + n − 2·LCS. This can exceed the Levenshtein distance, which may replace a letter in one step.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic