ProgrammingHard
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. The bucket count should not share a large factor with the key pattern, so a prime or mixed hash is preferred
- B. The hash must be the identity function
- C. Only the number of keys matters, not their values
- D. The table size must always be 8
Correct answer: A. The bucket count should not share a large factor with the key pattern, so a prime or mixed hash is preferred
With keys all multiples of 8 and 8 buckets, every key lands in bucket 0. Using a prime bucket count or a mixing step spreads the keys.
More C Programming questions
- 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?
- A hash table stores pointers to nodes allocated with malloc. What must happen when the table is destroyed?
- The expected number of probes for an unsuccessful search in linear probing with load factor a = 0.9 is about what?
- For a hash map of N = 10^5 entries with 10^5 lookups, which implementation is correct and fast enough in C?
- A chained table has a load factor of 3. A successful search compares the key against nodes until it is found. What is the expected number…