Question: Create a C++ program which utilizes cuckoo hashing to store data values, which will be provided from the text file raw_int.txt. Have each hash table
Create a C++ program which utilizes cuckoo hashing to store data values, which will be provided from the text file raw_int.txt. Have each hash table start at size 11, and rehash BOTH of your hashtables when either hashtable has a load factor greater than 0.5 [recall that load factor is (number of entries) / table size], or if you detect a cycle of insertion and displacement.
What is the final size of your hash tables?
Can you reduce the final table size with more efficient hashing algorithms?
Hash functions:
h1(x) = x mod m
h2(x) = (x/m) mod m
For rehashing:
update m using:
m = smallest prime number greater then 2m
m = m
Program Output requirements:
1. Output each individual move [i.e. 5 goes in table 1 slot 4. 6 goes in table 1 slot 4, 5 goes in table 2 slot 12. 14 goes in table 1 slot 9 . . . ]
2. When rehashing becomes necessary, display which table necessitated the rehashing [print out which table has a load factor greater than 0.5]. If rehashing became necessary due to a cycle of insertion and deletion, inform the user of which elements are involved in the cycle. Print out the new table size and the load factor of each new table once rehashing is complete.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
