Chaining, Universal Hashing & Search Complexity Under Load
“Separate chaining, load factor alpha, expected probe lengths, uniform hashing assumption, and universal hash families.”
1.Separate Chaining Complexity Analysis
§ 5.1.Under Simple Uniform Hashing, any key is equally likely to hash into any of the m slots, independently of other keys.
1. Unsuccessful Search:
The search traverses the entire linked list at slot h(k). The expected length of this list is the load factor alpha = n / m. Including the O(1) time to compute the hash function:
E[text{Cost}] = Theta(1 + alpha).
2. Successful Search:
The expected number of elements examined is 1 plus the expected number of elements inserted into the list after key x. On average, this is alpha / 2:
E[text{Cost}] = Theta(1 + alpha / 2).
2.Open Addressing Expected Probe Bounds
§ 5.2.In open addressing under the assumption of uniform hashing (each probe is equally likely to be any unoccupied slot):
- Unsuccessful Search: The probability that the first probe is occupied is alpha. The probability that the first two probes are occupied is alpha^2. Total expected probes:
E[P] = 1 + alpha + alpha^2 + alpha^3 + ... = frac{1}{1 - alpha}.
- Successful Search: Each key was inserted when the load factor was smaller. Integrating over the history yields:
E[P] = frac{1}{alpha} ln frac{1}{1 - alpha}.
3. Worked Problem: Expected Probes Calculation at High Load Factor
Use the natural logarithm ln, not base-10 log, in the successful search probe formula.
Problem: An open-addressed hash table using double hashing operates at a load factor of alpha = 0.75. Calculate the expected number of probes for an unsuccessful search and a successful search.
Step 1: Compute expected probes for Unsuccessful Search:
Formula: E[Unsuccessful] <= 1 / (1 - alpha)
Substitute alpha = 0.75 = 3/4:
E[Unsuccessful] <= 1 / (1 - 0.75) = 1 / 0.25 = 4 probes.
Step 2: Compute expected probes for Successful Search:
Formula: E[Successful] <= (1 / alpha) * ln(1 / (1 - alpha))
Substitute alpha = 0.75:
ln(1 / (1 - 0.75)) = ln(1 / 0.25) = ln(4) approx 1.3863.
E[Successful] <= (1 / 0.75) 1.3863 = (4 / 3) 1.3863 = 1.848 probes.
Final Answer: Unsuccessful search expects 4.0 probes; Successful search expects approximately 1.85 probes.
Primary Academic References & Exam Sources
Every concept in Notes From a B.Tech Brain is synthesized from authoritative academic texts, seminal peer-reviewed research, verified exam archives, and renowned university lectures.
Curated for clarity, rigorous numerical solving, and semester excellence:
Visual thinkers who want to see each algorithm step animated clearly.
GATE-targeted coverage with step-by-step GATE PYQ walkthroughs.