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:
| lwr | upr | % err | prime |
|---|---|---|---|
| 10.416667 | 53 | ||
| 1.041667 | 97 | ||
| 0.520833 | 193 | ||
| 1.302083 | 389 | ||
| 0.130208 | 769 | ||
| 0.455729 | 1543 | ||
| 0.227865 | 3079 | ||
| 0.113932 | 6151 | ||
| 0.008138 | 12289 | ||
| 0.069173 | 24593 | ||
| 0.010173 | 49157 | ||
| 0.013224 | 98317 | ||
| 0.002543 | 196613 | ||
| 0.006358 | 393241 | ||
| 0.000127 | 786433 | ||
| 0.000318 | 1572869 | ||
| 0.000350 | 3145739 | ||
| 0.000207 | 6291469 | ||
| 0.000040 | 12582917 | ||
| 0.000075 | 25165843 | ||
| 0.000010 | 50331653 | ||
| 0.000023 | 100663319 | ||
| 0.000009 | 201326611 | ||
| 0.000001 | 402653189 | ||
| 0.000011 | 805306457 | ||
| 0.000000 | 1610612741 |
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!
| Title | good hash table primes |
|---|---|
| Canonical name | GoodHashTablePrimes |
| Date of creation | 2013-03-22 12:57:37 |
| Last modified on | 2013-03-22 12:57:37 |
| Owner | akrowne (2) |
| Last modified by | akrowne (2) |
| Numerical id | 10 |
| Author | akrowne (2) |
| Entry type | Result |
| Classification | msc 68P05 |
| Classification | msc 68P10 |
| Classification | msc 68P20 |