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

Consider a hash table of size seven, with starting index zero, and a hash function (7x+3) mod 4. Assuming the hash table is initially empty, which of the following is the contents of the table when the sequence 1, 3, 8, 10 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: A. 3, 10, 1, 8, __ , __ , __

Explanation

h(x) = (7x + 3) mod 4: 1 → 2, 3 → 0, 8 → 3, 10 → 1. The table reads 3, 10, 1, 8, _, _, _.

More Data Structures and Algorithms questions