Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Input: 3 o i 9 i 6 i 3 i 15 i 12 i 9 i 3 d 3 d 15 i 1 i 7

image text in transcribed

Input:

3 o i 9 i 6 i 3 i 15 i 12 i 9 i 3 d 3 d 15 i 1 i 7 i 11 i 14 i 15 i 13 s 2 s 5 s 3 s 6 i 9 i 12 i 15 d 1 s 1 s 13 o e

Please help to output like such:

0 : 1 : 2 : ++++++++++++++++++++ 3 : DELETED ++++++++++++++++++++ 15 : DELETED ++++++++++++++++++++ 2 : NOT FOUND ++++++++++++++++++++ 5 : NOT FOUND ++++++++++++++++++++ 3 : FOUND AT 0,3 ++++++++++++++++++++ 6 : FOUND AT 0,4 ++++++++++++++++++++ 1 : DELETED ++++++++++++++++++++ 1 : NOT FOUND ++++++++++++++++++++ 13 : FOUND AT 1,0 ++++++++++++++++++++ 0 : 15->12->9->15->9->12->3->6->9 1 : 13->7 2 : 14->11 ++++++++++++++++++++

Hash Table with Chaining In this assignment you are requested to implement a hash table that handles collisions with chaining. You have to use linked lists, either from the Standard Template Library (STL) (rec- ommended) or by implementing your own. For usage of STL, refer for instance to here. You have to implement the insert, search and delete operations. The keys are integers (C++ int type) and you can assume that all keys k are non-negative. The first number in the input will be the size m of the chained hash table. You will use the simple hash function h(k)k mod m The input contains one of the following commands on a line: . i key: Insert key into the hash table. For example, "i 2" means "Insert key 2 into the hash table". For collisions, insert the colliding key at the beginning of the linked list. You just need to insert the key and do not have to output anything in this case. o d key: Delete key from the hash table. For example, "d 2" means "Delete key 2 from the hash table". Do nothing if the hash table does not contain the key. If there are multiple elements with the same key value, delete just one element. If the delete is successful, you have to output: keyDELETED If not (since there was no element with the given key), output: key DELETE FAILED . s key: Search key in the hash table. If there is an element with the key value, then you have to output: key : FOUND AT i, 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 do not find the key, then output: keyNOT FOUND o: Output the hash 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: Finish 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

Database Systems Design Implementation And Management

Authors: Peter Rob, Carlos Coronel

6th International Edition

061921323X, 978-0619213237

More Books

Students also viewed these Databases questions

Question

1. What are the peculiarities of viruses ?

Answered: 1 week ago

Question

Describe the menstrual cycle in a woman.

Answered: 1 week ago

Question

1. Identify what positions are included in the plan.

Answered: 1 week ago

Question

2. Identify the employees who are included in the plan.

Answered: 1 week ago