Why is chaining used in hash tables to handle collisions?
Think about how multiple items can share the same position in a hash table.
Chaining allows multiple elements to be stored at the same index by linking them together, usually with a linked list. This way, collisions do not overwrite existing data.
Which data structure is most commonly used to implement chaining in hash tables?
Consider a structure that allows easy insertion and traversal of multiple elements.
Linked lists are commonly used in chaining because they allow efficient insertion and traversal of elements that share the same hash index.
What happens to the average search time in a hash table using chaining when the number of elements greatly exceeds the number of buckets?
Think about what happens when many elements share the same bucket.
When many elements hash to the same bucket, the linked list (chain) grows longer, making search time proportional to the chain length, which increases linearly.
Which of the following is a key advantage of chaining over open addressing for collision handling?
Consider how elements are stored when collisions happen in both methods.
Chaining stores collided elements in separate linked lists, avoiding clustering issues common in open addressing where elements are stored within the array itself.
Given a hash table with 10 buckets using chaining, and 35 elements inserted, what is the minimum number of elements that must be in at least one bucket?
Use the pigeonhole principle to reason about distribution.
By the pigeonhole principle, with 35 elements and 10 buckets, at least one bucket must contain at least ceil(35/10) = 4 elements. If all buckets had 3 or fewer, the maximum total would be 30, which is less than 35.