15.1k views
4 votes
Consider a hash table of size seven, with starting index zero, and a hash function (3x + 4)mod7. 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? Note that ‘_’ denotes an empty location in the table.

A. 8, _, _, _, _, _, 10
B. 1, 8, 10, _, _, _, 3
C. 1, _, _, _, _, _,3
D. 1, 10, 8, _, _, _, 3

1 Answer

3 votes

Final answer:

To determine the contents of the hash table when the sequence 1, 3, 8, 10 is inserted using closed hashing, the correct answer is D. 1, 10, 8, _, _, _, 3.

Step-by-step explanation:

To determine the contents of the hash table when the sequence 1, 3, 8, 10 is inserted using closed hashing, we need to apply the hash function (3x + 4) mod 7. Here's how the sequence is inserted:

  1. Insert 1: (3 * 1 + 4) mod 7 = 0. Place 1 at index 0 of the hash table. The table now looks like this: 1, _, _, _, _, _, _
  2. Insert 3: (3 * 3 + 4) mod 7 = 6. Place 3 at index 6 of the hash table, but it's already occupied by 1, so use linear probing and place 3 at the next available index, which is 0. The table now looks like this: 1, _, _, _, _, _, 3
  3. Insert 8: (3 * 8 + 4) mod 7 = 5. Place 8 at index 5 of the hash table. The table now looks like this: 1, _, _, _, _, 8, 3
  4. Insert 10: (3 * 10 + 4) mod 7 = 1. Place 10 at index 1 of the hash table. The table now looks like this: 1, 10, _, _, _, 8, 3

So the correct answer is D. 1, 10, 8, _, _, _, 3.

User Sletheren
by
7.3k points