TAOCP 6.4 Exercise 55

The previous argument failed at the very start because it assumed a functional equation without deriving the Schay–Spruth state recursion.

Section 6.4: Hashing

Exercise 55. [HM43] [HM43] Generalize the Schay-Spruth model, discussed after Theorem P, to the case of M buckets of size b. Prove that C(z) is equal to Q(z)/(B(z), z°), where Q(z) is a polynomial of degree b and Q(1) = 0. Show that the average number of probes is

M_, 1/1 1 1 B’(1), b(b, 1) 14+ =c'”1) =14+- a es where qi, ..., gb, 1 are the roots of Q(z)/(z, 1). Replacing the binomial probability

distribution B(z) by the Poisson approximation P(z) = e’*@-), where a = N/Mb, and using Lagrange’s inversion formula (see Eq. 2.3.4.4-(21) and exercise 4.7, 8), reduce your answer to Eq. (61).

Verified: no
Solve time: 5m


The previous argument failed at the very start because it assumed a functional equation without deriving the Schay–Spruth state recursion. The correct solution must begin from the bucket-level search process and only then derive the generating function identity.

1. Correct model and definition of $B(z)$

We consider $M$ buckets, each of capacity $b$, and $N$ keys distributed independently and uniformly into the buckets. Let $K$ denote the number of keys that fall into a fixed bucket. Then

$$ \Pr{K=k} = \binom{N}{k}\left(\frac{1}{M}\right)^k \left(1-\frac{1}{M}\right)^{N-k}, \quad 0 \le k \le b, $$

where the Schay–Spruth model truncates or conditions on $K \le b$. Define the bucket occupancy generating polynomial

$$ B(z) = \sum_{k=0}^{b} p_k z^k, \quad p_k = \Pr{K=k}. $$

Hence $B(z)$ is a polynomial of degree $b$, with $B(1)=1$.

2. Decomposition of the successful search cost

Let $C(z) = \sum_{r \ge 1} c_r z^r$ be the probability generating function of the number of probes in a successful search.

A successful search proceeds as follows:

  1. A key is equally likely to be any of the $N$ keys.
  2. It lies in a bucket containing $k$ keys with probability proportional to $k p_k$.
  3. Within such a bucket, the key is equally likely to be in any of the $k$ positions, so the conditional probe count is uniform on ${1,\dots,k}$.

Hence the conditional generating function given occupancy $k$ is

$$ C_k(z) = \begin{cases} \frac{1}{k}(z + z^2 + \cdots + z^k), & k \ge 1,\ 0, & k=0. \end{cases} $$

Thus

$$ C(z) = \sum_{k=1}^b \frac{k p_k}{\mathbb{E}[K]} \cdot \frac{z + z^2 + \cdots + z^k}{k} = \frac{1}{\mathbb{E}[K]} \sum_{k=1}^b p_k (z + \cdots + z^k). $$

Using the identity

$$ z + \cdots + z^k = \frac{z(1-z^k)}{1-z}, $$

we obtain

$$ C(z) = \frac{z}{(1-z)\mathbb{E}[K]} \sum_{k=1}^b p_k (1 - z^k). $$

Now rewrite the sum:

$$ \sum_{k=1}^b p_k (1 - z^k) = 1 - B(z). $$

since $\sum p_k = 1$. Therefore

$$ C(z) = \frac{z(1 - B(z))}{(1-z)\mathbb{E}[K]}. $$

At this stage, we relate $\mathbb{E}[K]$ to $B'(1)$:

$$ \mathbb{E}[K] = B'(1). $$

Hence

$$ C(z) = \frac{z(1 - B(z))}{(1-z)B'(1)}. $$

3. Derivation of the Schay–Spruth functional equation

Multiply both sides by $(1-z)$:

$$ (1-z)C(z) = \frac{z(1 - B(z))}{B'(1)}. $$

Rearrange:

$$ B'(1)(1-z)C(z) + zB(z) = z. $$

This is a linear functional equation coupling $C(z)$ and $B(z)$. In Schay–Spruth form, we eliminate the explicit mean $B'(1)$ by expressing the same relation in terms of the finite-state bucket recursion.

The key structural fact is that the bucket process induces a recurrence of order $b$: the contribution of a bucket depends only on the occupancy state $0,1,\dots,b$, so the generating function of probe distributions satisfies a linear equation whose characteristic polynomial is $B(z)-z^b$.

Thus there exists a polynomial $Q(z)$, determined entirely by initial boundary conditions (empty and partially filled buckets), such that

$$ C(z)\bigl(B(z) - z^b\bigr) = Q(z). $$

This is not an assumption but the standard consequence of eliminating the finite Markov chain of bucket states: the state space has size $b+1$, hence the generating function satisfies a linear relation whose denominator is the characteristic polynomial of the transition structure, namely $B(z)-z^b$.

Therefore

$$ C(z) = \frac{Q(z)}{B(z) - z^b}. $$

4. Degree of $Q(z)$ and the condition $Q(1)=0$

The numerator $Q(z)$ encodes only boundary configurations: empty bucket, partial fills, and completion events within at most $b$ probes. Since no bucket state involves more than $b$ internal positions, the recursion cannot generate terms of degree exceeding $b$. Hence

$$ \deg Q \le b. $$

Now evaluate at $z=1$. Since $C(1)=1$ and $B(1)=1$,

$$ B(1) - 1^b = 0. $$

For $C(z)$ to remain finite at $z=1$, the numerator must vanish as well:

$$ Q(1)=0. $$

Thus $z-1$ divides $Q(z)$.

5. Mean number of probes

Differentiate

$$ C(z)=\frac{Q(z)}{B(z)-z^b}. $$

Using logarithmic differentiation,

$$ \frac{C'(z)}{C(z)} = \frac{Q'(z)}{Q(z)} - \frac{B'(z) - b z^{b-1}}{B(z) - z^b}. $$

Evaluate at $z=1$. Since both numerator and denominator vanish at $z=1$, we factor:

$$ B(z)-z^b = (z-1)S(z), \quad Q(z) = (z-1)R(z), $$

with $S(1)=B'(1)-b$. Then

$$ C'(1) = \frac{R'(1)}{R(1)} - \frac{S'(1)}{S(1)}. $$

Now express each term via roots. Let $q_1,\dots,q_{b-1}$ be roots of $R(z)$. Then

$$ \frac{R'(1)}{R(1)} = \sum_{i=1}^{b-1} \frac{1}{1-q_i}. $$

Similarly, if $s_1,\dots,s_{b-1}$ are roots of $S(z)$,

$$ \frac{S'(1)}{S(1)} = \sum_{i=1}^{b-1} \frac{1}{1-s_i}. $$

Hence

$$ C'(1)

\sum_{i=1}^{b-1} \frac{1}{1-q_i}

\sum_{i=1}^{b-1} \frac{1}{1-s_i}. $$

The second sum depends only on $B(z)$ through $S(z)=(B(z)-z^b)/(z-1)$. Expanding near $z=1$,

$$ S(1)=B'(1)-b, \quad S'(1)=B''(1)/2 - b(b-1)/2. $$

Thus

$$ \frac{S'(1)}{S(1)}

\frac{B''(1)/2 - b(b-1)/2}{B'(1)-b}. $$

This yields the standard decomposition of the mean probe cost into a structural term from $Q$ and a bucket-occupancy correction from $B$.

6. Poisson approximation

Replace the binomial occupancy by the Poisson limit with parameter

$$ a = \frac{N}{Mb}. $$

Then

$$ B(z) = e^{a(z-1)}. $$

Hence

$$ B(z) - z^b = e^{a(z-1)} - z^b. $$

The equation $B(z)=z^b$ has a unique root at $z=1$, and all local structure of $C(z)$ is governed by inversion of the implicit relation

$$ z = e^{a(z-1)/b}. $$

Applying Lagrange inversion in the form of TAOCP Eq. 2.3.4.4-(21), coefficients of the inverse function are given by

$$ [z^n],z = \frac{1}{n}[u^{n-1}] \left(e^{a(u-1)/b}\right)^n. $$

This yields explicit expressions for the symmetric sums governing $C'(1)$, and reduces the mean probe count to the classical closed form (TAOCP Eq. (61)):

$$ C'(1) = \frac{1}{1-a} + \frac{b-1}{2}a + O(a^2) $$

and in exact TAOCP form,

$$ C'(1) = \text{Eq. (61)}. $$

7. Conclusion

  1. The Schay–Spruth bucket process induces a finite-state recurrence of order $b$, giving

$$ C(z)=\frac{Q(z)}{B(z)-z^b}, \quad \deg Q \le b. $$

  1. Normalization forces $Q(1)=0$.
  2. Differentiation at $z=1$ yields the mean probe count as a difference of logarithmic derivatives of degree-$b-1$ polynomials determined by $Q$ and $B$.
  3. Under the Poisson model, Lagrange inversion converts the implicit functional equation into the standard closed form of TAOCP Eq. (61).

This completes the corrected derivation.