Why it matters
Rabin-Karp enables multi-pattern + fingerprinting. Understanding shapes hash-based matching.
Advertisement
The architecture
Rolling hash: h(text[i..i+m]) computed incrementally.
Compare hash first.
Verify on hash match.
Advertisement
How it works end to end
Polynomial rolling hash.
Modular arithmetic prevents overflow.
Verify: O(m) on hash hit.
Multi-pattern: hash set.