Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Objective: Create hash table class for storing strings Preliminary task: Create a hash table class that can be used to store strings. The class should

Objective: Create hash table class for storing strings

Preliminary task: 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

Files:

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

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

Database Principles Programming And Performance

Authors: Patrick O'Neil

1st Edition

1558603921, 978-1558603929

More Books

Students also viewed these Databases questions