Data Structures & AlgorithmsHardGATE CS

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

  1. A. 10
  2. B. 7
  3. C. 6
  4. D. 5

Correct answer: C. 6

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[6][8] = 6.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic