Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Hash Table with Chaining: Example of input and output The following example shows an execution of the program in interactive mode. See the input

C++ Hash Table with Chaining:

image text in transcribed

Example of input and output

The following example shows an execution of the program in interactive mode. See the input

files and output files under the testfiles folder for examples where input and output are separated.

2

i4

i2

i6

i3

o

0:6->2->4->;

1:3->;

s2

2:FOUND_AT0,1;

s4

4:FOUND_AT0,2;

d5

5:DELETE_FAILED;

d2

2:DELETED;

o

0:6->4->;

1:3->;

e

Then lines will follow starting with 'i', 's', 'd','o', or 'e'. The details are as follows: Use the hash function h(k) = k mod m i(key): Insert (key) into the table. For example, "i2" implies "Insert key 2 into the table." For collisions, insert the colliding key at the beginning of the linked list. You just need to insert the key and don't have to output anything in this case. d(key): delete (key) from the table. For example. d2 implies "Delete key 2 from the table." If there are multiple elements of the same key value, delete the element of the key value that appears the earliest in the list. If the delete was successful, you have to output (key) :DELETED; If not (since there was no element with the key value), output (key) :DELETE_FAILED; s(key): search (key) in the table. If there is an element with the key value, then you have to output (key) : FOUND_ATi,j; where i is the hash table index and j is the linked list index. If there are multiple elements with the same key value, choose the first one appearing in the linked list. If you couldn't find the key, then output (key) :NOT_FOUND; o: output the table. Output the entire hash table. Each line should begin with the 3 and slot hash table index followed by key values in the linked list. For example, if m we inserted 3, 6, and 1 into an empty table in this order, then you should output 0:6-3-> e: nnlsh your program

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

Databases A Beginners Guide

Authors: Andy Oppel

1st Edition

007160846X, 978-0071608466

More Books

Students also viewed these Databases questions

Question

What are the role of supervisors ?

Answered: 1 week ago

Question

2. Develop a persuasive topic and thesis

Answered: 1 week ago

Question

1. Define the goals of persuasive speaking

Answered: 1 week ago