Skip to content

Glossary: Algorithms Beyond the Basics in C++

KMP (string matching)

Also written: KMP, string matching

The Knuth-Morris-Pratt algorithm for finding a short pattern inside a longer text quickly. It runs in O(n + m) time by reusing what it already matched instead of starting over after a mismatch.

Where the book teaches it