next up previous
Next: Chapter 6: Priority Queues Up: CS 3345: Algorithm Analysis Previous: Chapter 4: Trees

Chapter 5: Hashing

Hashing
Hash Table:
an array of fixed size $Table\_Size$
Hash Function:
maps keys into numbers in the range $0-Table\_Size-1$
Goal:
distribute keys evenly among array
elements
Collision:
two keys hash to same value
Open Hashing (Separate Chaining)

Load Factor of Hash Table ($\lambda$)
# of elements in hash table / table size
Successful search:
$(1+\lambda/2)$ links traversed on average
Unsuccessful search:
$\lambda$ links traversed on
average
Therefore:

Open Addressing

\begin{displaymath}h_i(x) = (Hash(x) + f(i)) mod~Table\_Size\end{displaymath}

where f(0) = 0

Collision Resolution Strategies
Linear Probing: f(i) = iExpected number of probes:

Collision Resolution (contd.)
Quadratic Probing: f(i) = i2Double Hashing: $f(i) = i \times hash_2(x)$

Rehashing

Extendible Hashing


next up previous
Next: Chapter 6: Priority Queues Up: CS 3345: Algorithm Analysis Previous: Chapter 4: Trees
Ravi Prakash
1999-11-17