Your task for this assignment is to implement a database of student records. Your database will consist of two parts: an unsorted vector of student records, and an index of student IDs implemented as a closed hash table.
Student records will be stored in an unsorted vector of class Record. The definition of class Record will be provided for you in the file Record.h.
Your hash table should be implemented as an array of MAXHASH objects of class Slot. A Slot contains an integer key, and an integer value. The definition of class Slot will be provided for you in the file Slot.h. The value of MAXHASH should initially be #defined to 1000.
To implement the hash table, you should create a class called HashTable, implemented in the files HashTable.h and HashTable.cpp. Your class should support the following operations:
Because this is a closed hash, you will need both a hash function and a probe function. A hash function will be provided for you in the file hashfunction.h. Your hash must use pseudo-random probing to resolve collisions.
You should use your student database in a main program that allows a user to insert, search, and delete from the database. Searching the database by UID should be done using the hash table, and should report the number of collisions encountered during the search.
Deleting from the database removes both the hash table (index) entry, and the record store (vector) entry. You must delete records from the record store in a way that does not waste memory, and does not break the index. One way to do this is to copy the last record in the vector into the position holding the record to be deleted, and then use pop_back() to remove the last element of the vector.
Example program operation
Would you like to (I)nsert or (D)elete a record, or (S)earch for a record, or (Q)uit?
Enter action: I
Inserting a new record.
Last name: Doe
First name: Jane
UID: 1234
Year: Junior
Record inserted.
Would you like to (I)nsert or (D)elete a record, or (S)earch for a record, or (Q)uit?
Enter action: S
Enter UID to search for: 1234
Searching... record found (3 collisions during search)
----------------------------
Last name: Doe
First name: Jane
UID: 1234
Year: Junior
----------------------------
Would you like to (I)nsert or (D)elete a record, or (S)earch for a record, or (Q)uit?
Enter action: S
Enter UID to search for: 2345
Searching... record not found
Would you like to (I)nsert or (D)elete a record, or (S)earch for a record, or (Q)uit?
Enter action: Q
Exiting.