Longest chain after hashing
Hashing

Answer & solution
Official answer: 3
Step through it (11 steps)
Givens and goal
Insert keys 5,28,19,15,26,33,12,17,10 into a table with h(k)=k mod 9, resolving collisions by chaining. Find the longest chain length.
Approach
Group all keys by their remainder rather than by insertion adjacency.
Step-by-step solution
1. The nine remainders in order are 5,1,1,6,8,6,3,8,1. For example 28=3×9+1, 33=3×9+6, and 17=1×9+8.
2. Bucket 1 receives 28,19,10; bucket 3 receives 12; bucket 5 receives 5; bucket 6 receives 15,33; bucket 8 receives 26,17. Buckets 0,2,4,7 remain empty.
3. The nonempty chain lengths are therefore 3,1,1,2,2, summing to 9 as a consistency check with the number of inserted keys.
4. The maximum is 3. Whether chaining inserts at the head or tail changes order inside a bucket but not its length. Do not apply linear probing: the problem explicitly stores collisions in chains.

