Reuse the last comparison
transcript
A text of a hundred thousand letters. Sort every ending of the text. Compare them two at a time. Each comparison may be long.
There are a hundred thousand suffixes. Sorting them takes about one point seven million comparisons. Each may compare a hundred thousand letters. That is a hundred and seventy billion.
A comparison shows where texts agree. Keep that, and start after it. Never start from scratch twice.
Each entry is a border length. At c, the match is lost. Then a, b, a rebuild the border. A failure falls back, never restarts.
The prefix function falls back to a shorter border. The suffix array doubles the compared length. Aho-Corasick follows failure links.
Doubling needs seventeen rounds. The prefix function needs one pass. Aho-Corasick needs one pass too.
Never compare from scratch twice. Keep the matched prefix. Linear time follows. A hundred and seventy billion becomes a pass. Full breakdown in the lecture.