Separate chaining
A way to handle collisions in a hash table: each bucket keeps a list of every pair that lands there.
Example
If 136 and 236 land in bucket 36, that bucket's list becomes 136 → 236 and neither is lost.
Test yourself: Separate chaining
Hash collisions
What does each bucket hold in a hash table with separate chaining?
If 136 and 236 land in bucket 36 of 100, both end up in bucket 36's list: 136 → 236.
Hash collisions
In Java, a bucket's list is turned into a tree when it reaches ___ nodes.
With 8 nodes the list looks up in up to 8 steps; a balanced tree of 8 does it in about 3. With 1,000 nodes, 1,000 against about 10.
0/2
â–¶ Play