Data Structures & AlgorithmsHardGATE CS · Codeforces Div 2

Strings a = "bccbc" and b = "bbacaa". The edit distance allows insert, delete and substitute, each costing 1 (the standard Levenshtein distance). What is the edit distance between a and b?

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

Correct answer: C. 4

The DP table gives 4. The insertion–deletion distance (no substitution) gives 5, which overcounts substitutions.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic