Question: Hash.h ( need to fill in more code ) 3 . Assignment Description You are required to develop a C + + program that reads
Hash.h need to fill in more code
Assignment Description
You are required to develop a C program that reads an input data set consisting of the following four parts see inputtxt for one example
The first part first line is a hash table size.
The second part is a list of HotelBooking objects, this part will end with the line InsertionEnd
The third part is a list of commands that need to be executed, such as 'hashLoadFactor', 'hashDisplay', 'hashSearch', 'hashDelete', etc.
The forth part last line is the command 'End' which terminates the program.
After reading in a hash table size reresented by an integer a hash table of the size collision resolidg by chaining needs to be created. Each slot of your hash table should be a LinkedList of nodes where each node represents one HotelBooking object. Initially all linked lists should be empty.
Then by reading each HotelBookings information line by line, their information needs to be stored inside the hash table using a hash function. In this assignment, you're required to design your own hash function based on each HotelBooking's associative key. Each HotelBooking's associative key is the combination of hotelName, arrivalDate and confirmNum. You should designtest your hash function in such a way that it maximumly reduces the number of collisions, ie the HotelBooking objects should be evenly distributed into each slot and the length of each linked list should not be too long this will be measured by performance ratio defined below
Class Description
The LinkedList class
struct HotelBooking
string hotelName, arrivalDate;
int confirmNum;
struct HotelBooking next;
;
For the linked list of HotelBooking class LinkedList.h you need to create a pointer head that points to the first element of the linked list initially it should be set to NULL Also you need to create the following functions inside the LinkedList class within LinkedList.h file See below for the class definition:
class LinkedList
private:
struct HotelBooking head;
int size;
public:
LinkedList;
~LinkedList;
HotelBooking getHead;
int getSize;
bool searchBookingstring hotelName, string arrivalDate, int confirmNum;
bool insertBookingstring hotelName, string arrivalDate, int confirmNum;
bool deleteBookingstring hotelName, string arrivalDate, int confirmNum;
void displayList;
;
Note: for collision resolving by chaining mechnasim, when two or more than two bookings are hashed into the same slot, the newest HotelBooking should always be inserted at the front of the LinkedList.
The Hash class
The Hash.h file represents a hash table which is a one dimensional array of LinkedList. See below for the class definition. Note: feel free to add extra auxillary functions if you feel they make your coding easier, but your Hash class must at least contain the following functions.
class Hash
private:
LinkedList hashTable; hashTable is a onedimensional array of LinkedList
int m; slots number of the hash table
public:
Hashint size;
~Hash;
bool hashSearchstring hotelName, string arrivalDate, int confirmNum;
bool hashInsertstring hotelName, string arrivalDate, int confirmNum;
bool hashDeletestring hotelName, string arrivalDate, int confirmNum;
double hashLoadFactor;
void hashDisplay;
int hashFunctionstring key;
;
AttributeFunction AttributeFunctions Description
LinkedList hashTable; This private attribute represents the underline data structure, ie a hashTable is a dynamicallymemoryallocated one dimensional array of LinkedList LinkedList class is defined above already
int m; This private attribute represents the hash table size, ie number of slots in one dimensional array of hashTable.
Hashint size; This is the constructor of Hash class. It will initialize both hashTable and m attributes. Specially hashTable should be initialize to a one dimensional array of size LinkedList.
~Hash; This is the destructor of Hash class. First it need to delete each LinkedList from each slot, it then delete the whole table and release all occupied memory.
bool hashSearchstring hotelName, string arrivalDate, int confirmNum; Given a HotelBooking's key combination of hotelName, arrivalDate and confirmNum this function first ca
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
