I have a question about choosing the q and d in Rabin-Karp algorithm for searching strings. The algorithm uses the values q as modulus and d as hash function.
If I choose q as number of power 2 and d=q-1 or d=q+1
How can these choices affect spurious hits?
What patterns will be sure spurious hits in case d=q+1 and in case d=q-1?