Data Structures & AlgorithmsHardGATE CS · Product-company placement

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

  1. A. 8
  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 = 6 + 9 − 2·2 = 11. The unit-cost edit distance (8) is the trap.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic