Question Id : 18432 |
Context : UGC NET Computer Science June 2023 (Paper II)
Consider a hash table of size seven with starting index zero and a hash function $(6x + 3) \mod 4$. Assuming the hash table is initially empty. Which of the following is the content of the table when the sequence 1, 3, 8, 10, 5 is inserted into the table using closed hashing? Here “_______” denotes an empty location in the table.
🎥 Video solution / Text Solution of this question is given below:
Hash function:
$h(x) = (6x + 3) \mod 4$
For 1:
$h(1) = 9 \mod 4 = 1$
So, 1 is placed at index 1.
For 3:
$h(3) = 21 \mod 4 = 1$
Index 1 is occupied, so place 3 at next free index 2.
For 8:
$h(8) = 51 \mod 4 = 3$
So, 8 is placed at index 3.
For 10:
$h(10) = 63 \mod 4 = 3$
Index 3 is occupied, so place 10 at index 4.
For 5:
$h(5) = 33 \mod 4 = 1$
Index 1, 2, 3, 4 are occupied, so place 5 at index 5.