Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE READ CAREFULLY: CODE IN C++ Hash table with open addressing. In this assignment you are requested to implement insert, search, and delete operations for

PLEASE READ CAREFULLY: CODE IN C++

Hash table with open addressing.

In this assignment you are requested to implement insert, search, and delete operations for an open-addressing hash table with double hashing. Create an empty hash table of size m = 13. Each integer of the input will be a key that you should insert into the hash table. Use the double hashing function h(k, i) = (h1(k) + ih2(k)) mod 13 where h1(k) = k mod 13 and h2(k) = 1 + (k mod 11). The input terminates when the key 1 is read (such a key must not be inserted in the hash table). At that point, print the content of the hash table to the screen (see sample input/output below for the printing format). Then, read integers from the input until the number 2 is found (do not process that number). For each number inputted, print the index of the element in the hash table. If the number is not inside the hash table, print NOT FOUND. Finally, read integers from the input until the number 3 is found (do not process that number). For each number inputted, delete it from the hash table (note that the integer might not be in the table). Once the integer 3 is found, print the hash table. CODE IN C++ PLEASE

image text in transcribed

TEST

INPUT:

0 13 26 39 52 65 78 91 104 117 130 143 156 -1 13 45 26 1 2 3 22 39 0 45 46 47 52 65 78 91 104 117 130 1256 478 143 678 987 145 178 963 2499 32195 156 7 -2 45 26 1 2 3 22 39 0 45 47 65 78 91 117 1256 478 143 678 987 145 178 963 2499 32195 156 7 -3

EXPECTED OUTPUT:

0 143 78 13 91 26 104 39 117 52 130 65 156 3 NOT_FOUND 5 NOT_FOUND NOT_FOUND NOT_FOUND NOT_FOUND 7 0 NOT_FOUND NOT_FOUND NOT_FOUND 9 11 2 4 6 8 10 NOT_FOUND NOT_FOUND 1 NOT_FOUND NOT_FOUND NOT_FOUND NOT_FOUND NOT_FOUND NOT_FOUND NOT_FOUND 12 NOT_FOUND

13

104

52 130

Hash table with open addressing In this assignment you are requested to implement insert, search, and delete operations for an open-addressing hash table with double hashing. Create an empty hash table of size m = 13, Each integer of the input will be a key that you should insert into the hash table. Use the double hashing function h(k, i) = (h1(k) + iha(k)) mod 13 where hi(k) = k mod 13 and h2(k) = 1 + (k mod 11). The input terminates when the key-1 is read (such a key must not be inserted in the hash table). At that point, print the content of the hash table to the screen (see sample input/output below for the printing format). Then, read integers from the input until the number -2 is found (do not process that number). For each number inputted, print the index of the element in the hash table. If the number is not inside the hash table, print NOT_FOUND. Finally, read integers from the input until the number -3 is found (do not process that number). For each number inputted, delete it from the hash table (note that the integer might not be in the table). Once the integer -3 is found, print the hash table Hash table with open addressing In this assignment you are requested to implement insert, search, and delete operations for an open-addressing hash table with double hashing. Create an empty hash table of size m = 13, Each integer of the input will be a key that you should insert into the hash table. Use the double hashing function h(k, i) = (h1(k) + iha(k)) mod 13 where hi(k) = k mod 13 and h2(k) = 1 + (k mod 11). The input terminates when the key-1 is read (such a key must not be inserted in the hash table). At that point, print the content of the hash table to the screen (see sample input/output below for the printing format). Then, read integers from the input until the number -2 is found (do not process that number). For each number inputted, print the index of the element in the hash table. If the number is not inside the hash table, print NOT_FOUND. Finally, read integers from the input until the number -3 is found (do not process that number). For each number inputted, delete it from the hash table (note that the integer might not be in the table). Once the integer -3 is found, print the hash table

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

Spatial Databases A Tour

Authors: Shashi Shekhar, Sanjay Chawla

1st Edition

0130174807, 978-0130174802

More Books

Students also viewed these Databases questions