Data Structures & AlgorithmsHardGATE CS

Edit distance between PARAGRAPH and BINARY where insert and delete cost 1 each but a substitution costs 2: what is the minimum total cost?

  1. A. 7
  2. B. 13
  3. C. 12
  4. D. 11

Correct answer: D. 11

With substitution = 2 it is never cheaper than delete + insert, so the cost is |a| + |b| − 2·LCS = 9 + 6 − 2·2 = 11. The unit-cost edit distance (7) is the trap.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic