Data Structures & AlgorithmsHardGATE CS · Product-company placement

What is the edit distance (insert, delete, substitute; each cost 1) between RECESSION and HEAPSORT?

  1. A. 11
  2. B. 9
  3. C. 6
  4. D. 7

Correct answer: D. 7

Fill the (|a|+1) × (|b|+1) table with D[i][j] = min(D[i−1][j] + 1, D[i][j−1] + 1, D[i−1][j−1] + [aᵢ ≠ bⱼ]); D[9][8] = 7.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic