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?

  1. A. The bucket count should not share a large factor with the key pattern, so a prime or mixed hash is preferred
  2. B. The hash must be the identity function
  3. C. Only the number of keys matters, not their values
  4. 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

Exams that ask this topic