Data Structures & AlgorithmsHardProduct-company placement

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

  1. A. 13
  2. B. 8
  3. C. 14
  4. D. 12

Correct answer: A. 13

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic