1

Let's take the hash function from the Rabin-Karp algorithm as an example.

Let $T$ be an array of characters. The polynomial hash of the substring $T[0..i]$ is given by:
$h(i) = T[0]b^i + T[1]b^{i-1} + ... + T[i]$ ,
where $b \in \mathbb N$.
It's recurrence relation formula is given by:
$h(i) = h(i-1)b + T[i]$

If we enclose the formulas with the mod m operator, the new recurrence relation stays true:
$h_{mod}(i) = (h_{mod}(i-1)b + T[i])\mod m$
where $m \in \mathbb N$.

Does the above behaviour apply to all recurrence relations? Or to a subset of recurrence relations, for example recurrence relations containing only sum and product operations?

Bill Dubuque
  • 272,048

0 Answers0