TAOCP 6.4 Exercise 33

Equation (51) gives the approximation \[ C_N \approx \frac{1}{2}\left(1 + \frac{1}{1-\alpha}\right) \] for the average number of probes in a successful search using Algorithm L (linear probing), where...

Section 6.4: Hashing

Exercise 33. ▶ [M23] Explain why (51) is only an approximation to the true average number of probes made by Algorithm L. What was there about the derivation of (51) that wasn’t rigorously exact?

Verified: no
Solve time: 4m19s


Solution

Equation (51) gives the approximation [ C_N \approx \frac{1}{2}\left(1 + \frac{1}{1-\alpha}\right) ] for the average number of probes in a successful search using Algorithm L (linear probing), where (\alpha = N/M) is the load factor. This formula is derived by assuming that the hash function distributes keys uniformly and independently over the (M) table positions, and that the resulting pattern of occupied cells is statistically equivalent to a random configuration in which each cell is independently occupied with probability (\alpha). Under this independence assumption, the length of a run of occupied cells follows a geometric distribution, and the expected search cost reduces to the closed form (51).

The derivation is not rigorous because the independence assumption is false for linear probing. The algorithm places each key into the first empty cell at or after its hash address; this creates clustering,positive correlations between the occupancies of adjacent cells. Consequently, the probability that a given cell is occupied is not independent of the state of its neighbors, and the distribution of run lengths is not exactly geometric. The exact analysis (given later in the section using the circular table model and parking functions) accounts for these correlations and yields a different, more complicated expression for the true average number of probes. Equation (51) is therefore only an approximation, although it becomes asymptotically exact as (M, N \to \infty) with (\alpha) fixed. The non‑rigorous step is precisely the replacement of the true dependent occupancy process by an independent Bernoulli process.