DATA STRUCTURES/Student Engineering Notebook
Page 09·notes
HASHING, COLLISION DYNAMICS & DISJOINT SETS—~32 MIN READ

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

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

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}.

WORKED EXAM ANALYSIS · STEP-BY-STEP DERIVATION

3. Worked Problem: Expected Probes Calculation at High Load Factor

⚠️ Pitfall Warning:

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.

WORKED NUMERICAL · STUDENT DERIVATION✎ Key Takeaway: Chaining stays usable even with α > 1; open addressing needs α < 1.

Worked example: expected search cost with chaining

Problem Statement:
2000 keys are stored in a chained hash table with 500 slots, assuming simple uniform hashing. What is the expected cost of an unsuccessful search?
Step 1: Load factor

α = n/m.

2000/500
↳ Result: α = 4
Step 2: Unsuccessful search

Hash to a slot, then scan its whole chain, whose expected length is α.

Θ(1 + α)
Step 3: Plug in

One hash computation plus about 4 key comparisons.

Final Answer:About 1 + 4 = 5 steps (4 key comparisons on average)
STUDENT PRACTICE · CONCEPT DRILL

Practice: test yourself

Original practice questions in the GATE style, with worked explanations. Not past-paper questions.

Problem 1 · FOUNDATION

A chained table has m = 100 slots and n = 250 keys. What is the load factor?

Problem 2 · GATE-LEVEL

With a universal family of hash functions, the probability that two distinct keys collide is at most:

Problem 3 · GATE-LEVEL

With chaining and simple uniform hashing, a successful search takes on average:

SOURCE TRANSPARENCY & CITATIONS

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 University Lecture Series
Introduction to Algorithms (4th Edition) ·
LECTURE SERIES
RECOMMENDED YOUTUBE EDUCATORS & FULL-COURSE PLAYLISTS

Curated for clarity, rigorous numerical solving, and semester excellence:

Abdul Bari · Data Structures & Algorithms↗Instructor: Abdul Bari · Covers: Trees, graphs, hashing, sorting — with visual algorithm animations

Visual thinkers who want to see each algorithm step animated clearly.

Open YouTube↗
Gate Smashers · Data Structures Full Course↗Instructor: Varun Singla · Covers: Arrays, linked lists, trees, BST, AVL, heaps, hashing — GATE numericals

GATE-targeted coverage with step-by-step GATE PYQ walkthroughs.

Open YouTube↗