Keys 15, 22 and 8 are inserted in that order into a hash table of size 7 using h(k) = k mod 7 and linear probing. At which index is 8 stored?
Correct answer B. 3
Explanation
15 mod 7 = 1, so 15 goes to index 1. 22 mod 7 = 1 collides, and linear probing tries the next slot, index 2. 8 mod 7 = 1 collides, index 2 is taken, so it moves on to index 3, which is free. Linear probing's tendency to build such runs of occupied slots is called primary clustering.
Answer checked How we write and check questions
Discussion