Data Structures & AlgorithmsHardProduct-company MCQ pattern

Keys 57, 11, 34, 33, 80, 9, 72, 24, 56, 66 are inserted via separate chaining (h(k) = k mod 7, new keys appended to the end of the chain) into a table of size 7 (buckets 0 to 6). What are the final bucket contents, and what is the longest chain length?

  1. A. 72, 57, 9, 80, 11, 33, 34 — longest chain 1
  2. B. 56, 57, 9→72, 80→24→66, 11, 33, 34 — longest chain 3
  3. C. 56, 57, 72→9, 66→24→80, 11, 33, 34 — longest chain 3
  4. D. 56, 57, 9→72, 80→24→66, 11, 33, 34 — longest chain 2

Correct answer: B. 56, 57, 9→72, 80→24→66, 11, 33, 34 — longest chain 3

Each key is appended to the chain at index k mod 7 in insertion order, giving buckets [56, 57, 9→72, 80→24→66, 11, 33, 34], whose longest chain has 3 key(s). This differs from open addressing (linear probing), which would spread keys like [72, 57, 9, 80, 11, 33, 34] into single-slot buckets instead of chains.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic