Explain Rabin-Karp Algorithm.

Explain Rabin-Karp Algorithm.

Approach: Describe a string matching algorithm using rolling hashes.

A string-searching algorithm that uses hashing to find any one of a set of pattern strings in a text. It calculates a rolling hash for the text and compares it to the pattern hash.

Follow-up: What is the worst-case complexity?

Key concepts: rolling hash, O(n+m) average, collisions.