A Hash Function f is defined as f(key) = key mod 7. With linear probing, while…
2016
A Hash Function f is defined as f(key) = key mod 7. With linear probing, while inserting the keys 37, 38, 72, 48, 98, 11, 56 into a table indexed from 0, in which location the key 11 will be stored (Count table index 0 as 0thlocation)?
- A.
3
- B.
4
- C.
5
- D.
6
Attempted by 231 students.
Show answer & explanation
Correct answer: C
The hash function is f(key) = key mod 7. Insert keys sequentially: 37%7=2 (Index 2), 38%7=3 (Index 3), 72%7=2 (Collision, probe to Index 4). 48%7=6 (Index 6), 98%7=0 (Index 0). For key 11: 11%7=4 (Collision with 72), probe to Index 5 which is empty. Key 11 stores at location 5.
A video solution is available for this question — log in and enroll to watch it.