Beginner Topic 12 of 52 Data Structures
Chaining
Collision strategy storing colliding entries in per-bucket lists.
How it works
In separate chaining each bucket holds a linked list, or a small tree, of all entries that hash to it. Insertion appends to the chain, and lookup hashes to a bucket and scans its chain. With a good hash function and load factor near one, chains stay short and operations are O(1) on average. Chains grow gracefully as the load rises, though lookup time grows with them.
Where it is used
Java HashMap, many language runtimes and database hash joins use chaining. It is simple to implement and deletion is straightforward, because nodes are just unlinked.
Common pitfall
Long chains from poor hashing degrade to O(n) time. Pointer chasing hurts cache performance and each node adds memory overhead. Resize when the load factor passes a threshold, and consider converting long chains into balanced trees as Java does to resist attacks.
Where it fits in the course
Chaining is topic 12 of 52 in Data Structures, rated Beginner. It follows Hash Collisions. The next topic is Open Addressing.
Practice and explore
- Open the interactive lesson, with a mini quiz.
- Take the Data Structures quiz.
- Explore the Hash Table visualizer: Hash function, buckets and chaining collisions.
How to study this topic
- Read the explanation above and restate the definition in your own words.
- Open the interactive lesson and answer its mini quiz.
- Read the common pitfall, then write a short example that avoids it.
- Check your understanding in the Data Structures quiz, and revisit the topic if you miss a question.
Frequently asked questions
What is Chaining?
Where do people use Chaining?
What is the most common mistake with Chaining?
What should I learn before this topic?
How can I practice it?
Is Chaining hard to learn?
How long does it take to learn Chaining?
Which topics are related to Chaining?
What should I study after Chaining?
Related topics
- Hash Collisions (Data Structures)
- Open Addressing (Data Structures)
- Hash Tables (Data Structures)
- Trees (Data Structures)