Home▸Algorithms & AI▸Rabin-Karp Rolling Hash String Search: Hash Along the Text (2D)

Rabin-Karp Rolling Hash String Search: Hash Along the Text (2D)

The same Rabin-Karp search on a flat belt of letter tiles with the window hash plotted along the text. Compare letter comparisons with the naive search and watch spurious collisions follow the 1/q law.

Algorithms & AI2DAdvanced60 FPS📱 Mobile-adapted🟠 Blender⇄ 3D version
Rabin-Karp Rolling Hash String Search: Hash Along the Text (2D) ↗ Open standalone

A belt of wooden letter tiles slides under a brass reading frame while a rolling polynomial hash is updated in constant time per step. Change the text length, pattern length, alphabet, base and modulus to see hash hits, true matches, spurious collisions and how many letter comparisons Rabin-Karp saves against the naive search. Blender-built tiles and frame, with numerical checks built in.

⚙ Under the hood

The same Rabin-Karp search on a flat belt of letter tiles with the window hash plotted along the text. Compare letter comparisons with the naive search and watch spurious collisions follow the 1/q law.

Rabin-KarpRolling HashString SearchHash CollisionsAlgorithms

2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)