Knuth–Morris–Pratt (KMP) — step by step

Watch the pattern slide across the text. On a mismatch, KMP jumps using the prefix function π instead of restarting, so each text character is examined at most twice.

Text T (window = characters currently aligned with the pattern)

Pattern P (green = matched prefix of length j) · π shown above each cell

Current step

Press Load, then Step.
Matches found so far: —
aligned window matched full match mismatch