Homework 8: Hashing & Hash Tables
Assigned: Thursday November 18, 2010 Due: Monday November 22, 2010 by 11:59pm
(10 points) What are the advantages and disadvantages of Open Addressing and Separate Chaining
collision resolution strategies?
Advantages Disadvantages
Open Addressing • Memory Efficient – stores • Creates Clusters with Linear and
elements in empty array Quadratic Probing
spaces
Separate Chaining • Very Easy to implement • Memory Inefficient – requires a
secondary data structure to store
collisions
• Long Chains will produce Linear
search times
(10 points) Given input {4371, 1323, 6173, 4199, 4344, 9679, 1989} and a hash function
h x =x mod 10 , show the resulting Hash Table using a secondary hash function
h 2 x =7 – x mod 7
4371 1323 6173 9679 4344 4199
Cannot insert 1989 because it collides after both hash functions have been applied.
(5 points) Given a hash table size of 1009 containing 656 elements that uses Linear Probing collision
resolution. What is the approximate number of probes necessary to insert the 657th element?
=656/1009=0.650148662
1 1 1 1 1
probes= 1 2
= 1 2
= 18.1702044=5
2 1− 2 1−0.650148662 2