String matching
Locate every occurrence of a pattern and see how prefix reuse avoids repeated work.
Step forward, return to an earlier state, or scrub the timeline. Applying input begins a new run. Switching compatible algorithms retains the input; other algorithms load their own defaults.
Current state
Operation history
Pseudocode
Each highlighted line corresponds to an operation in the executable trace. Counts describe core algorithm work, excluding validation, snapshots, and rendering.
Read the executable JavaScriptExplore the lessons
- Naïve string matching — Try the pattern at every possible starting position.
- Knuth–Morris–Pratt search — Reuse matched prefixes instead of restarting after a mismatch.
Follow the changing state
The data display shows each algorithm’s own variables and intermediate answers. Pink marks current work, amber marks dependencies or a divisor, and green marks a result. Each lesson explains its display, prerequisites, performance, and limitations.