Data Structures & AlgorithmsHardGATE CS

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

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

Correct answer: B. 11

With substitution = 2 it is never cheaper than delete + insert, so the cost is |a| + |b| − 2·LCS = 7 + 8 − 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