Edit Distance: From Memorization to Derivation

About this lecture

Dynamic programming taught as something you derive rather than something you recognise. Starting from two short words, sun and sand, the lecture states the subproblem in a single sentence, then asks the one question that produces a recurrence: what was the last edit? Each of delete, insert and substitute is argued from what it does to the two prefixes and drawn as an arrow from the neighbouring cell it comes from. The twenty cell table is then filled one square at a time, with three live arrows pointing into whichever square is being computed, so the dependence of a cell on its neighbours is watched rather than described. The same arrows are walked backwards to recover the actual sequence of edits, and the finished table is counted against the hundred and ninety three calls the naive recursion would have made on the same two words.

Transcript

Loading discussion…