Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hash Table Study in C++ Required: 1 Header file and 1 Driver File Create a hash table class that can be used to store strings.

Hash Table Study in C++

Required: 1 Header file and 1 Driver File

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

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 add.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 search.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:

image text in transcribed

image text in transcribed

Make sure your program is properly documented and good programming standards are followed.

----------------------------------------------add.txt-----------------------------------------------------------

air balloon car den elf fun giraffe iodine jolly kelvin 

----------------------------------------search.txt-----------------------------------------

air loon park den elf funny gaffe dine jolly kelvin 
Hash table built with a total of 4 collisions 0: kelvin 1: 2: car 3 den 4: elf 5: iodine 6: balloon 7: joll;y 8: air 9: giraffe 10: fun Hash table built with a total of 4 collisions 0: kelvin 1: 2: car 3 den 4: elf 5: iodine 6: balloon 7: joll;y 8: air 9: giraffe 10: fun

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Contemporary Issues In Database Design And Information Systems Development

Authors: Keng Siau

1st Edition

1599042894, 978-1599042893

More Books

Students also viewed these Databases questions