<?xml version="1.0" encoding="UTF-8"?>

<record version="6" id="3327">
 <title>good hash table primes</title>
 <name>GoodHashTablePrimes</name>
 <created>2002-08-21 04:02:13</created>
 <modified>2004-02-24 23:37:14</modified>
 <type>Result</type>
<parent id="3326">hashing</parent>
 <creator id="2" name="akrowne"/>
 <author id="2" name="akrowne"/>
 <classification>
	<category scheme="msc" code="68P20"/>
	<category scheme="msc" code="68P10"/>
	<category scheme="msc" code="68P05"/>
 </classification>
 <preamble>\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsfonts}

%\usepackage{psfrag}
%\usepackage{graphicx}
%\usepackage{xypic}</preamble>
 <content>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:

\begin{enumerate}

\item each number in the list is prime (as you no doubt expected by now)
\item each number is slightly less than twice the size of the previous
\item each number is as far as possible from the nearest two powers of two

\end{enumerate}

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:

\begin{center}
\begin{tabular}{lllc}
lwr &amp; upr &amp; \% err &amp; prime  \\
\hline
$2^{5}$ &amp; $2^{6}$ &amp; 10.416667 &amp; 53 \\
$2^{6}$ &amp; $2^{7}$ &amp; 1.041667 &amp; 97 \\
$2^{7}$ &amp; $2^{8}$ &amp; 0.520833 &amp; 193 \\
$2^{8}$ &amp; $2^{9}$ &amp; 1.302083 &amp; 389 \\
$2^{9}$ &amp; $2^{10}$ &amp; 0.130208 &amp; 769 \\
$2^{10}$ &amp; $2^{11}$ &amp; 0.455729 &amp; 1543 \\
$2^{11}$ &amp; $2^{12}$ &amp; 0.227865 &amp; 3079 \\
$2^{12}$ &amp; $2^{13}$ &amp; 0.113932 &amp; 6151 \\
$2^{13}$ &amp; $2^{14}$ &amp; 0.008138 &amp; 12289 \\
$2^{14}$ &amp; $2^{15}$ &amp; 0.069173 &amp; 24593 \\
$2^{15}$ &amp; $2^{16}$ &amp; 0.010173 &amp; 49157 \\
$2^{16}$ &amp; $2^{17}$ &amp; 0.013224 &amp; 98317 \\
$2^{17}$ &amp; $2^{18}$ &amp; 0.002543 &amp; 196613 \\
$2^{18}$ &amp; $2^{19}$ &amp; 0.006358 &amp; 393241 \\
$2^{19}$ &amp; $2^{20}$ &amp; 0.000127 &amp; 786433 \\
$2^{20}$ &amp; $2^{21}$ &amp; 0.000318 &amp; 1572869 \\
$2^{21}$ &amp; $2^{22}$ &amp; 0.000350 &amp; 3145739 \\
$2^{22}$ &amp; $2^{23}$ &amp; 0.000207 &amp; 6291469 \\
$2^{23}$ &amp; $2^{24}$ &amp; 0.000040 &amp; 12582917 \\
$2^{24}$ &amp; $2^{25}$ &amp; 0.000075 &amp; 25165843 \\
$2^{25}$ &amp; $2^{26}$ &amp; 0.000010 &amp; 50331653 \\
$2^{26}$ &amp; $2^{27}$ &amp; 0.000023 &amp; 100663319 \\
$2^{27}$ &amp; $2^{28}$ &amp; 0.000009 &amp; 201326611 \\
$2^{28}$ &amp; $2^{29}$ &amp; 0.000001 &amp; 402653189 \\
$2^{29}$ &amp; $2^{30}$ &amp; 0.000011 &amp; 805306457 \\
$2^{30}$ &amp; $2^{31}$ &amp; 0.000000 &amp; 1610612741 
\end{tabular}
\end{center}

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.

Bon hash\'etite!</content>
</record>
