Consider a hash table with 10 slots. What is the sequence of the following…
2023
Consider a hash table with 10 slots. What is the sequence of the following elements in a hash table if the hash function is k mod 10 and the collision is resolved using linear probing? 44, 26, 12, 93, 80, 57, 56, 23, 46, 36
- A.
80, 46, 12, 93, 44, 23, 26, 57, 56, 36
- B.
80, 36, 12, 93, 44, 23, 26, 57, 56, 46
- C.
80, 36, 12, 93, 44, 23, 26, 56, 46, 57
- D.
12, 23, 26, 36, 44, 46, 56, 57, 80, 93
Attempted by 93 students.
Show answer & explanation
Correct answer: B
Using k mod 10 and linear probing: 44->4, 26->6, 12->2, 93->3, 80->0, 57->7, 56 collides and goes to 8, 23 collides and goes to 5, 46 collides through 6-8 and goes to 9, 36 collides through 6-9 and goes to 1. The table is 80, 36, 12, 93, 44, 23, 26, 57, 56, 46.