next up previous
Next: Up: Previous:

Multiplication Method



h(k) = \(\lfloor m (kA \;mod\; 1) \rfloor\), where 0<A<1

(kA mod 1) returns the fractional part of kA.



In this case the choice of m is less critical. Typically choose a power of 2 to simplify arithmetic.



However, the choice of A does matter. A recommendation is to use

\begin{displaymath}A \;=\; \frac{\sqrt{5} - 1}{2} \;=\; 0.6180339887 ...\end{displaymath}

The worst choice is A = 0.5, because in this case every key hashes to \(\lfloor \frac{m}{2} \rfloor\) or 0.


next up previous
Next: Up: Previous: