Question: Hi, I need to create a C++ program hashing table that search the students based on their ID from a file. Description Write a program
Hi, I need to create a C++ program hashing table that search the students based on their ID from a file.
Description
Write a program that provides for searching students by their ids using hash table. The program will first input students one by one from a file (insert.txt) and insert them into hash table. Then it will input students one by one from a text file (search.txt) and perform searches for them in the hash table. It will keep a record of searches when required and display the summary results.
Implementation
Class StudentHT
Create a class StudentHT that provides for the following struct definitions, instance variables and methods.
struct RecType contains student id, first name, and last name.
struct NodeType contains student id, first name, last name, and a pointer to NodeType
hashPtr an instance variable pointing to hash table array of pointers
a constructor to input hash table size
void insert (RecType item)
will insert an item in the hash table.
item search (RecType item)
Will search an item in hash table and will return it. If not found will return an item containing -1 for id.
void startStatistics ();
void endStatistics ();
void displayStatistics();
Main Method
Provide main method that will create the hash table object and call its methods.
Hashing Algorithm
Calculate the hash index from student id as below:
hash index = (student id) % (total entries in hash table)
Statistics
Provide the following statistics
Total number if ids searched
Total number of nodes searched
Average number of nodes search per id searched
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
