Data Structures & AlgorithmsHardCodeforces Div 2 · ICPC regional

Strings a = "bcbbba" and b = "accc". 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. 6
  2. B. 5
  3. C. 8
  4. D. 2

Correct answer: B. 5

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic