ProgrammingModerate
A hash table with 10 buckets receives 11 keys. What is the minimum number of collisions guaranteed?
- A. At least one bucket holds two keys, by the pigeonhole principle
- B. No collision is guaranteed, since the keys could all be different
- C. At least 11 collisions
- D. Exactly 10 collisions
Correct answer: A. At least one bucket holds two keys, by the pigeonhole principle
Eleven keys in ten buckets force some bucket to hold two or more keys, so at least one collision must occur.
More C Programming questions
- Which C code correctly inserts a node n at the front of bucket h of an array of struct node table[]?
- Which operation is needed to make open addressing deletions safe for later lookups?
- A program counts the distinct keys among 10^6 values by inserting them into a hash set with expected O(1) operations. What is the expected…
- Which property of the hash function matters most to avoid long chains when keys are multiples of 8 and the table has 8 buckets?
- A table of size 7 with h(k) = k % 7 is filled with 7 keys using linear probing and no deletions. How many more keys can be inserted before…
- Which search code is correct for an open-addressing table of size m with linear probing, where an empty slot ends the search?