Knuth Morris Pratt KMP Algorithm
suggest changeIntroduction
The KMP is a pattern matching algorithm which searches for occurrences of a “word” W within a main “text string” S by employing the observation that when a mismatch occurs, we have the sufficient information to determine where the next match could begin.We take advantage of this information to avoid matching the characters that we know will anyway match.The worst case complexity for searching a pattern reduces to O(n).
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents