Data Structures & AlgorithmsHardICPC regional · GATE CS top band

Strings a = "acbc" and b = "aabc". 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. 2
  2. B. 4
  3. C. 1
  4. D. 0

Correct answer: C. 1

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic