Data Structures & AlgorithmsHardGATE CS · Product-company placement

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

  1. A. 16
  2. B. 12
  3. C. 10
  4. D. 9

Correct answer: C. 10

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic