Saturday, July 4, 2015

Knuth-Morris-Pratt algorithm for String Matching


https://www.youtube.com/watch?v=kBW6oPaVjq0

Need a prefix table.

The preprocessing is very similar to string matching.
One is to match pattern to itself. The other is to match pattern to text.
Time complexity: O(m) + O(n)  ( O(m) for preprocessing and O(n) for matching).

No comments: