Why it matters

Rabin-Karp is standard for multi-pattern search. Rolling hash is key idea.

Advertisement

The architecture

Compute pattern hash.

Rolling hash over text.

Verify on match.

Rabin-Karp string searchPattern hashcompute onceRolling hashover textVerifyon hash matchKarp-Rabin 1987; great for multi-pattern; verification prevents false match
Rabin-Karp string search.
Advertisement

How it works end to end

Karp-Rabin 1987.

Rolling hash.

Multi-pattern via hash set.