All mock tests are FREE till 31 December — register to save your progress

Consider a hash table of size seven with starting (6x + 3) mod 4 index zero and a hash function . Assuming the hash table is initially empty. Which of the following is the content of the table when 1, 3, 8, 10, 5 the sequence , is inserted into the table using closed hashing? Here "__ " denotes an empty location in the table.

Pick an option to check yourself, or open the answer below.

Show answer & explanation

Correct answer: D. _1,3,8,10,5_ C + +

Explanation

h(1) = 9 mod 4 = 1 → slot 1. h(3) = 21 mod 4 = 1 → taken, slot 2. h(8) = 51 mod 4 = 3 → slot 3. h(10) = 63 mod 4 = 3 → slot 4. h(5) = 33 mod 4 = 1 → next free is 5. Table: _, 1, 3, 8, 10, 5, _.

More Data Structures and Algorithms questions