0% found this document useful (0 votes)
26 views2 pages

Solution 8

The document discusses hashing and hash tables, including advantages and disadvantages of open addressing and separate chaining collision resolution strategies. It provides an example of a hash table implementation using separate chaining with a secondary hash function. It also calculates the approximate number of probes needed to insert an element into a hash table using linear probing.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views2 pages

Solution 8

The document discusses hashing and hash tables, including advantages and disadvantages of open addressing and separate chaining collision resolution strategies. It provides an example of a hash table implementation using separate chaining with a secondary hash function. It also calculates the approximate number of probes needed to insert an element into a hash table using linear probing.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 2

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
= 18.1702044=5
2 1− 2 1−0.650148662 2

You might also like