GATE Computer ScienceVery hardNIELIT Scientist B

Rabin–Karp searches for the digit pattern 26 in the text 3141592653589793, treating each 2-digit window as a decimal number reduced modulo 11. How many spurious hits (equal hash, different string) occur?

  1. A. 4
  2. B. 2
  3. C. 5
  4. D. 3

Correct answer: D. 3

26 mod 11 = 4; counting the windows with value ≡ 4 (mod 11) that are not 26 gives 3.

More Algorithms questions

Exams that ask this topic