good hash table primes
In the course of designing a good hashing configuration![]()
, it is helpful to have a list of prime numbers for the hash table size.
The following is such a list. It has the properties that:
- 1.
each number in the list is prime
- 2.
each number is slightly less than twice the size of the previous
- 3.
each number is as far as possible from the nearest two powers of two
Using primes for hash tables is a good idea because it minimizes clustering in the hashed table. Item (2) is nice because it is convenient for growing a hash table in the face of expanding data. Item (3) has, allegedly, been shown to yield especially good results in practice.
And here is the list:
The columns are, in order, the lower bounding power of two, the upper bounding power of two, the relative deviation (in percent) of the prime number![]()
from the optimal middle of the first two, and finally the prime itself.
Happy hashing!