good hash table primes


In the course of designing a good hashing configurationMathworldPlanetmathPlanetmath, 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. 1.

    each number in the list is prime

  2. 2.

    each number is slightly less than twice the size of the previous

  3. 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
25 26 10.416667 53
26 27 1.041667 97
27 28 0.520833 193
28 29 1.302083 389
29 210 0.130208 769
210 211 0.455729 1543
211 212 0.227865 3079
212 213 0.113932 6151
213 214 0.008138 12289
214 215 0.069173 24593
215 216 0.010173 49157
216 217 0.013224 98317
217 218 0.002543 196613
218 219 0.006358 393241
219 220 0.000127 786433
220 221 0.000318 1572869
221 222 0.000350 3145739
222 223 0.000207 6291469
223 224 0.000040 12582917
224 225 0.000075 25165843
225 226 0.000010 50331653
226 227 0.000023 100663319
227 228 0.000009 201326611
228 229 0.000001 402653189
229 230 0.000011 805306457
230 231 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 numberMathworldPlanetmath 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