MakarovSuites
English
EnglishDeutschРусскийУкраїнськаFrançaisEspañolItalianoPolski
Contact & licences

Math

String search: KMP, Boyer–Moore, Rabin–Karp

Compare naive, KMP, full Boyer–Moore and rolling-hash substring search, with recorded comparisons, prefix tables and overlapping matches.

String search: KMP, Boyer–Moore, Rabin–Karp — Actual application image
Actual application image

Try this

Compare actual character checks on your own text. KMP uses a prefix table; Boyer–Moore combines bad-character and good-suffix shifts; Rabin–Karp verifies rolling-hash candidates. Counts describe the complete search; playback reveals its recorded comparisons.

Equations used in the module
Equations
KMP prefix π[i]: longest proper prefix that is also a suffix
Boyer–Moore shift = max(bad-character, good-suffix)
Rabin–Karp: hnext = ((h−old·bᵐ⁻¹)b+new) mod p
Hash matches are verified character by character; overlapping matches are retained

Related experiments

Back to catalogue
Mazes: generate and solve — Actual application image

Math

Mazes: generate and solve

Generate mazes with depth-first carving, Prim and Wilson, then compare breadth-first, A* and wall-following routes.