Question: C++ language Edit: using Division (Modular arithmetic) for the hash function Create a hash table class that can be used to store strings. The class

C++ language

Edit: using Division (Modular arithmetic) for the hash function

Create a hash table class that can be used to store strings. The class should provide the functionality for the following operations: Adding an element Searching for an element Calculating the hash for an element (see textbook) Printing the hash table For both searching and adding, collisions should be resolved with linear probing. In your driver file, create an object of your string hash table with size 11. Read from the file hw8add.txt and insert the elements to the hash table. Keep a running total of the number of collisions that occur during construction of the table. Print the total number of collisions to the screen. When the table is built, print the contents to the screen. Read from the file hw8search.txt and search the hash table for the items listed. For each element, display whether or not it was found. If it was found, its index in the table should be displayed, otherwise dont print an index value. Print the number of collisions that occurred searching for the element and keep a running total. Finally, print the total number of collisions that occurred searching for the items in file.

Below is an example of sample output: Hash table built with a total of 4 collisions

0: kelvin

1: loon

2: car

3: den

4: elf

5: iodine

6: balloon

7: jolly

8: air

9: giraffe

10: fun

KEY FOUND INDEX COLLISIONS air YES 8 0 NO 1 park NO 0 den YES 3 0 elf YES 4 1 funny NO 2 gaffe NO 2 dine NO 3 jolly YES 7 3 kelvin YES 0 0 Keys searched with a total of 12 collisions

==============================

hw8add.txt:

air balloon car den elf fun giraffe iodine jolly kelvin

======================

hw8search.txt

air loon park den elf funny gaffe dine jolly kelvin

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!