Dynamic Programming21 sections · 916 units
Open in Course

Edit Distance - The Three Operations

Insert, delete, replace

Let's understand each operation: Insert: Add a character. "CAT" becomes "CART". Delete: Remove a character. "CART" becomes "CAT". Replace: Change one character. "CAT" becomes "CAR". Each operation costs 1.

This problem appears everywhere: spell checkers, DNA analysis, diff tools. For 'intention' and 'execution', the minimum edit distance is 55 operations. Spell checkers use this to suggest the nearest matching word.