Question: IIn this project, you will implement an important data structure called the hash table. This project requires you to implement a hash table to fulfill
IIn this project, you will implement an important data structure called the hash table. This project requires you to implement a hash table to fulfill the functionality provided by project and project You will first implement a singly linked list class SLL in SLLh file, then implement HashTable class that is in hashTable.h file. Lastly, implement projectcpp file. Please read this handout before coding. A node.h file is provided. Do NOT change the node.h file. The end of this handout has important guidelines to be used in testing.
Your Implementation:
This project includes three parts:
Implement the unfinished methods of the SLL class in the SLLh file, do NOT change anything in the node.h file. SLL must be class TEMPLATE. Use
placeholder wherever you do not want to use fixed data type.
Implement HashTable class, which is class template, in hashTable.h file. The default constructor uses as the table size. The constructor with parameter uses the parameter value as the table size. Do not hardcode array size in your constructors. Let the user decide what array size will be
Implement projectcpp file, which creates a HashTable object with parameter for the constructor. The constructor of HashTable uses this prime number to build an internal SLL object array. Each element of the array is an SLL object. Of course, you can choose a different array size, but make sure the size is a prime number.
There are multiple input files included in the zip file. Please note that we have new files whose data set sizes are larger than the files of the previous projects.
To compile the source code, you can type the following command:
gWall projectcpp o project
Hints:
Because the SSN values are evenly distributed in the input files, the hash
function in your implementation can be as simple as hk k mod m where m is the table size.
Your program should work with all the provided input files, including the
idr.
The executable file will be project If your hash table implementation is right, when we execute file project the result looks like the following contents:
projectidr
The Number of Valid Insertion:
The Number of Valid Deletion:
The Number of Valid Retrieval:
Item numbers in the list:
Time elapsed:
projectidr
The Number of Valid Insertion:
The Number of Valid Deletion:
The Number of Valid Retrieval:
Item numbers in the list:
Time elapsed:
projectidr
The Number of Valid Insertion:
The Number of Valid Deletion:
The Number of Valid Retrieval:
Item numbers in the list:
Time elapsed:
projectidr
The Number of Valid Insertion:
The Number of Valid Deletion:
The Number of Valid Retrieval:
Item numbers in the list:
Time elapsed:
SLLh
#include iostream
#include "node.h
using namespace std;
template
class SLL
Node headPtr;
int size;
public:
default constructor
SLL
implement this method
destructor
~SLL
implement this method
Node getHeadPtr
return headPtr;
insert item item to the list
void insertU item U item
implement this method
if find the item value, return the pointer to the node
otherwise, return nullptr
Node searchU item
implement this method
remove the node with key value: item
bool removeU item
implement this method
int getSize
return size;
display the SSN values of each node in the linked list
void display
Node temp;
temp headPtr;
while temp nullptr
cout tempSSN endl;
temp tempnext;
;
hashTable.h
#include iostream
#include SLLh
using namespace std;
template
class HashTable
int tableSize; table size
SLL table;
public:
default constructor, which uses default table size
HashTable
tableSize ;
table new SLLtableSize;
constructor, which use size as the table size
HashTableint size
implement this method
search item in the table
if found, return true; otherwise, return false
bool findV item
implement this method
insert item item to the table
use item as the key
if inserted, return true
otherwise, return false
bool insertV item V item
implement this method
delete the pair whose key value is item
if deleted, return true
otherwise, return false
bool eraseV item
implement this method
return the total number of nodes in the hash table
int getSize
implement this method
;
Node.h
#include iostream
using namespace std;
template
struct Node
T SSN;
T name;
Node next;
;
projectcpp
#include iostream
#include fstream
#include "hashTable.h
#include string
#include time.h
#include ctime
using namespace std;
int mainint argc, char argv
implement this missing part
make the array size inside the hash table is
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
