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.
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.
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.
2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install