next up previous
Next: Universal Hashing Up: CSE 2320: Algorithms and Previous: Example

Multiplication Method

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

(kA mod 1) returns the part of kA.

In this case the choice of m is less critical. Typically choose a power of 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 , because in this case every key hashes to \(\lfloor \frac{m}{2} \rfloor\) or 0.

Copyright © 1998 The University of Texas at Arlington