Also called Karp-Rabin algorithm and Rolling hash search.
fresh numbers
The test's questions that a run answers, asked again on new numbers whenever you like. The answer, its working and the reason for every other choice come from rabin-karp's own run on the numbers shown.
choose one
1question 1
Rabin-Karp looks for kzax in mhrupmkzax. The fingerprints agree only at places 5 and 7. How many letter comparisons does it make?
the answer, and why
the answer is D
Place 5, pmkz: p is not k, 1. Place 7, kzax: k, z, a and x match, 4. No other place compares. That is 5.
if you chose another
AThat compares all 4 letters at both places, but place 5 stops at its first letter.
BThat counts only the match, not the chance agreement at place 5.
CThat compares all 4 letters at all 7 places, the most any search of 10 letters and 4 could make.
Each text has ten letters and each pattern five. Which makes Rabin-Karp compare the fewest letters?
the answer, and why
the answer is D
Letters are compared only where the fingerprints agree, by chance or because the pattern is there. dadadaadda, aaadd compares 0 letters, the fewest of the four.