Skip to content

Rabin-Karp

words

Level 2 of 3

Also called Karp-Rabin algorithm and Rolling hash search.

Finds every place a pattern stands in a text by comparing numbers before letters. Each piece of text as long as the pattern gets a fingerprint, a number from 0 to 10. Only where it agrees with the pattern's are the letters compared, and each fingerprint comes cheaply from the one before.

the text, with the pattern under it

the fingerprint of the text under the pattern at each place

letters compared
0
fingerprints worked out
0

step 1 of 1

Examples

A text of 2 to 10 letters, then a pattern of 1 to 6 letters, a to z only, separated by a comma or a space, for example banana, ana.