Get the latest tech news

Knuth–Morris–Pratt illustrated


Knuth–Morris–Pratt illustrated - Volume 34

Sedgewick & Wayne present a related algorithm for minimal DFA construction, with greater memory consumption than KMP, and simply assert that it can be improved. The naive O( nm) algorithm for string search attempts to match the pattern at every position in the text. Finally, the check function determines whether the candidate at the top of acc matches the current character of the text:

Get the Android app

Or read this on Hacker News