Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Hash Tables (1 Header File and 1 Driver File) PLEASE SHOW RAN THROUGH A TERMINAL Create a hash table class that can be used

C++ Hash Tables (1 Header File and 1 Driver File) PLEASE SHOW RAN THROUGH A TERMINAL

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:

Hash table built with a total of 4 collisions

0: kelvin

1:

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

loon 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

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 

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

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

1583473858, 978-1583473856

More Books

Students also viewed these Databases questions

Question

2. Why?

Answered: 1 week ago

Question

1. Where do these biases come from?

Answered: 1 week ago