Correct : 3
The correct answer is 3.
We apply the hash function h(k) = k mod 9 to each of the 9 keys and group them by their hash slot. Collisions are resolved by chaining, so each slot holds a linked list of all keys that map to it.
Computing the hash for each key: 5 mod 9 = 5, 28 mod 9 = 1, 19 mod 9 = 1, 15 mod 9 = 6, 26 mod 9 = 8, 33 mod 9 = 6, 12 mod 9 = 3, 17 mod 9 = 8, 10 mod 9 = 1.
Grouping by slot: Slot 1 → {28, 19, 10} — chain length 3. Slot 6 → {15, 33} — chain length 2. Slot 8 → {26, 17} — chain length 2. Slot 3 → {12} — chain length 1. Slot 5 → {5} — chain length 1. All other slots are empty.
The longest chain is at slot 1, which contains three keys — 28, 19, and 10 — all of which yield a remainder of 1 when divided by 9. The length of the longest chain is therefore 3.
Similar Questions
Total Unique Visitors