Rabin-Karp Algorithm
Preprocessing – convert a string (pattern) into some hash that is faster to compare. • Let’s say we have the string “hello world”, and let’s assume that its hash is hash(‘hello world’) = 12345. Searching – So if hash(‘he’) = 1 we can say that the pattern “he” is contained in the text “hello world”. – Thus on every step we take from the text a sub-string with the length of m, where m is the pattern length. Thus we hash this sub-string and we can directly compare it to the hashed pattern.