Please help! I am having trouble with hash tables. 1) Given the input {4371, 132
ID: 3815689 • Letter: P
Question
Please help! I am having trouble with hash tables.
1) Given the input {4371, 1323, 6173, 4199, 4344, 9679, 1989, 2525}, a fixed table size of 10, and a hsh function of H(X) = X % 10, show the result of inserting all of the elements using linear probing to resolve collisions. (Place null in the unused locations.)
2) Given the input {4371, 1323, 6173, 4199, 4344, 9679, 1989, 2525}, a fixed table size of 10, and a hsh function of H(X) = X % 10, show the result of inserting all of the elements using quadratic probing to resolve collisions. (Place null in the unused locations.)
3) Given the input {4371, 1323, 6173, 4199, 4344, 9679, 1989, 2525}, a fixed table size of 10, and a hsh function of H(X) = X % 10, show the result of inserting all of the elements using separate chaining to resolve collisions.
(Place null in the unused locations. If multiple elements are in the same location, add to the front of the chain and separate elements with a comma and a space. For example: 1234, 2234, 3334).
Explanation / Answer
Hash table using linear probing:
Index 0 1 2 3 4 5 6 7 8 9 H(4371) = 4371 % 10 = 1 4371 H(1323) = 1323 % 10 = 3 4371 1323 H(6173) = 6173 % 10 = 3 (probed once) 4371 1323 6173 H(4199) = 4199 % 10 = 9 4371 1323 6173 4199 H(4344) = 4344 % 10 = 4 (probed once) 4371 1323 6173 4344 4199 H(9679) = 9679 % 10 = 9 (probed once) 9679 4371 1323 6173 4344 4199 H(1989) = 1989 % 10 = 9 (probed 4 times) 9679 4371 1989 1323 6173 4344 4199 H(2525) = 2525 % 10 = 5 (probed once) 9679 4371 1989 1323 6173 4344 2525 4199