Data Structures & AlgorithmsHardProduct placement · Amazon/Microsoft

Keys 55, 63, 47, 69, 16, 97, 39, 99, 77, 43 are inserted in this order into a chained hash table with 7 buckets, h(k) = k mod 7, and each new key is placed at the HEAD of its chain. A successful search compares keys along the chain. How many key comparisons does a search for 55 make, and what is the longest chain length?

  1. A. comparisons: 1; longest chain: 3
  2. B. comparisons: 2; longest chain: 3
  3. C. comparisons: 3; longest chain: 4
  4. D. comparisons: 3; longest chain: 3

Correct answer: D. comparisons: 3; longest chain: 3

Bucket 6 receives 55, 69, 97 in that order; head insertion reverses them, so 55 (inserted first) is at the tail and takes 3 comparisons.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic