Question: Write a program to implement a hash table. You may use linear probing method to resolve collisions. Use the following hash function h(x) = x

Write a program to implement a hash table. You may use linear probing method to resolve collisions. Use the following hash function h(x) = x mod (size of the table). Choose the appropriate class definition for the hash table based on the collision resolving method that you select.

I am using the following class definition for Linear Probing or Quadratic Probing:

class hashtable {

public:
hashtable (int size);//Allocate space for the hash tables based on the
//parameter size.  Set the size and the count.
void Insert(int value); //insert the value in the hash table
void display();         //Display the content of the hash table1.
bool Isfull();  //return true if the hast table is full, otherwise return false

private:
int * table; // hash table
int count;  //number of values stored in the hash table
int size; //size of the hash table
};
How do I First ask the user for the table size and let your program be menu driven using the following menu options:

Option 1 – Insert a value into the hash tables
Option 2 – Display the hash table
Option 3 – Exit Program
Sample output for the display method using the following:

Table size is 10. Values are stored in the following order: 285, 280, 365, 476, 385, 165, 285, 165, 163, 180, 280, 165

Output from display method using chaining:

0 – 180-1, 280-2
1 –
2 –
3 – 163-1
4 –
5 – 165-3, 285-2, 365-1, 385-1
6 – 476-1
7 –
8 –
9 –
Output from display method using linear probing:

0 – 280-2
1 – 180-1
2 –
3 – 163-1
4 –
5 – 285-2
6 – 365-1
7 – 476-1
8 – 385-1
9 – 165-3

Output from display method using quadratic probing:

0 – 280-2
1 – 180-1
2 –
3 – 163-1
4 – 385-1
5 – 285-2
6 – 365-1
7 – 476-1
8 –
9 – 165-3

Step by Step Solution

3.42 Rating (158 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To create a hash table with linear probing and the specified functionalities we will design a class in C This class will include methods to insert a v... View full answer

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 Programming Questions!