Knuth-Morris-Pratt
Finds every place a pattern stands in a text without reading a text letter again once it has matched. A table from the pattern gives each start's border, the longest piece that both begins and ends it. After a mismatch, the pattern moves on so that border lines up under what already matched.
the text, with the pattern under it
the border of each start of the pattern, the longest piece that both begins and ends it
- letters compared
- 0
step 1 of 1
Examples