1

I am having a hard time understanding the Rabin-Karp algorithm with modulo arithmetic. My questions.

  1. Why we use modulus to determine the hash of the string being analyzed?

  2. How to determine the modulus to be used?

shehan chanuka
  • 71
  • 1
  • 10
  • 2
    Read https://en.wikipedia.org/wiki/Rabin%E2%80%93Karp_algorithm#Hash_function_used which explains the rationale for the hash function, and how the modulus is chosen. – Stephen C May 16 '22 at 00:07

0 Answers0