Question: #include #include using namespace std; /* This is code for linear probing in open addressing. If you want to do quadratic probing and double hashing

 #include #include using namespace std; /* This is code for linear
#include
#include
using namespace std;
/*
This is code for linear probing in open addressing. If you want to do quadratic probing and double hashing which are also
open addressing methods in this code when I used hash function that (pos+1)%hFn in that place just replace with another function.
*/
void Insert(int ary[],int hFn, int Size){
int element,pos,n=0;
cout
cin>>element;
pos = element%hFn;
while(ary[pos]!= INT_MIN) { // INT_MIN and INT_MAX indicates that cell is empty. So if cell is empty loop will break and goto bottom of the loop to insert element
if(ary[pos]== INT_MAX)
break;
pos = (pos+1)%hFn;
n++;
if(n==Size)
break; // If table is full we should break, if not check this, loop will go to infinite loop.
}
if(n==Size)
cout
else
ary[pos] = element; //Inserting element
}
void Delete(int ary[],int hFn,int Size){
/*
very careful observation required while deleting. To understand code of this delete function see the note at end of the program
*/
int element,n=0,pos;
cout
cin>>element;
pos = element%hFn;
while(n++ != Size){
if(ary[pos]==INT_MIN){
cout
break;
}
else if(ary[pos]==element){
ary[pos]=INT_MAX;
cout
break;
}
else{
pos = (pos+1) % hFn;
}
}
if(--n==Size)
cout
}
void Search(int ary[],int hFn,int Size){
int element,pos,n=0;
cout
cin>>element;
pos = element%hFn;
while(n++ != Size){
if(ary[pos]==element){
cout
break;
}
else
if(ary[pos]==INT_MAX ||ary[pos]!=INT_MIN)
pos = (pos+1) %hFn;
}
if(--n==Size)
cout
}
void display(int ary[],int Size){
int i;
cout
for(i=0;i
cout
}
int main(){
int Size,hFn,i,choice;
cout
cin>>Size;
int ary[Size];
cout
cin>>hFn;
for(i=0;i
ary[i]=INT_MIN; //Assigning INT_MIN indicates that cell is empty
do{
cout
cout Insert 2-> Delete 3-> Display 4-> Searching 0-> Exit ";
cin>>choice;
switch(choice){
case 1:
Insert(ary,hFn,Size);
break;
case 2:
Delete(ary,hFn,Size);
break;
case 3:
display(ary,Size);
break;
case 4:
Search(ary,hFn,Size);
break;
default:
cout
break;
}
}while(choice);
return 0;
}
3. The hash table array has capacity of 10. Capacity is the number of slots present in the array that is used to build the hashtable. The hash function returns the absolute value of the key mod the capacity of the hash table. a) Insert these keys in the hash table: 3,23.11.21.1.7.77,8 where the hash table uses quadratic probing to resolve collisions. b) Search and Delete 3 and 11 from the table. Be careful about changing the status of the table slot to "deleted" after deleting each item. c)Search 23 and 21 from the table and print their position. Hint and help: You can use and modify the code provided for hush table in the class to solve your problem. Please write the full code in answer script here. If you only copy the class code without answering the question you will not get any marks. You have to write all three parts (a), (b) and (c) in one code under one main function

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!