Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

Develop a C++ program that reads an input data set consisting of four parts:

Develop a C++ program that reads an input data set consisting of four parts: the first part is a hash table size requested by a user; the second part is a list of athletes with a medal, this part will end with the line “InsertionEnd”; the third part is a number of commands to follow; and the forth part is a list of commands.

1. After reading in a hash table size requested by a user, a hash table of the size (with chaining) needs to be created. Each slot of your hash table should be a link list of nodes where each node represents one athlete. Initially all linked lists should be empty.

2. Then by reading each athlete information line by line, their information needs to be stored in the hash table using a hash function. You will need to design your hash function so that it reduces the number of collisions, i.e., the length of each linked list should not be too long.

-->Each athlete data will be in one line and will contain: discipline, gender, team_or_ind,event, venue, medal, athlete, and country that are separated by commas.The following shows an example of such data for athletes:

Archery,M,TEAM,Archery,Lord's Cricket Ground,1. GOLD,team ITA,Italy

Archery,M,TEAM,Archery,Lord's Cricket Ground,2. SILVER,team USA,United States

Archery,M,TEAM,Archery,Lord's Cricket Ground,3. BRONZE,team KOR,South Korea

Cycling,M,IND,Road,Regent's Park,1. GOLD,Aleksander Winokurow,Kazakhstan

Cycling,M,IND,Road,Regent's Park,2. SILVER,Rigoberto Uran,Colombia

Cycling,M,IND,Road,Regent's Park,3. BRONZE,Alexander Kristoff,Norway

Fencing,F,IND,Foil,ExCeL,1. GOLD,Elisa Di Francisca,Italy

Fencing,F,IND,Foil,ExCeL,2. SILVER,Arianna Errigo,Italy

Fencing,F,IND,Foil,ExCeL,3. BRONZE,Valentina Vezzali,Italy

3. After the line “InsertionEnd”, a user will enter a number of commands.

4. Each command will be “hash_display”, “hash_search”, or “hash_delete”.Hash_Display command:With “hash_display” command, your program needs to display the content of your hashtable by listing the content of each linked list in the following format, by specifying theindex of each slot of the hash table and their linked list size (if a linked list is empty, itshould print out “The list is empty”:

index: 0, linked list size: 3

discipline: Cycling

gender: F

team_or_ind: IND

event: Road

venue: Regent's Park

medal: 1. GOLD

athlete: Marianne Vos

country: Netherlands

discipline: Swimming

gender: F

team_or_ind: IND

event: Medley

venue: Aquatics Centre

medal: 3. BRONZE

athlete: Xuanxu Li

country: China

discipline: Fencing

gender: F

team_or_ind: IND

event: Foil

venue: ExCeL

medal: 1. GOLD

athlete: Elisa Di Francisca

country: Italy

index: 1, linked list size: 2

discipline: Swimming

gender: M

team_or_ind: IND

event: Freestyle

venue: Aquatics Centre

medal: 2. SILVER

athlete: Tehwan Park

country: South Korea

discipline: Judo

gender:M

team_or_ind: IND

event: 60

venue: ExCeL

medal: 3. BRONZE

athlete: Rishod Sobirov

country: Uzbekistan

Hash_Search command:

Hash_Search command will have the format of:

hash_search,discipline,gender,event,athlete where the word “hash_search” is followed by discipline, gender, event and athlete,and they are separated by commas. A real example of such command can be:

hash_search,Shooting,F,Pistol,Jongoh Jin

After the hash_search command is entered, the program should search for an athlete that matches those data fields, and if it is found, display their information with their medal type as:

The medal recipient Jongoh Jin has the medal of 1. GOLD

If not found, display a message using the following format:

Jongoh Jin for Shooting with event Pistol not found

Hash_Delete command:

Hash_Delete command will have the format of:

hash_delete,discipline,gender,event,athlete

where the word “hash_delete” is followed by discipline, gender, event and athlete,and they are separated by commas.A real example of such command can be:

hash_delete,Swimming,M,Medley,Thiago Pereira

After the hash_delete command is entered, the program should search for an athlete that matches those data fields, and if it is found, it should be deleted from the hash table and the program needs to display a message using the following format using their information:

The medal recipient Thiago Pereira for Swimming with event Medley deleted

If not found, display a message using the following format:

Thiago Pereira for Swimming with event Medley not found

**You should create a hash table with chaining (an array of linked lists). Please specify your hash function h(k) clearly. The key for each athlete data will be a string made by appending their discipline, gender, event, and athlete. For instance, for the athlete with the information:

“Cycling,M,IND,Road,Regent's Park,1. GOLD,Aleksander Winokurow,Kazakhstan”

, the key will be “CyclingMRoadAleksander Winokurow “.

You also need to define INSERT,SEARCH, and DELETE functions for the hash table,and define INSERT,SEARCH, and DELETE functions for the linked list. Please have comments to clearly identify these functions in your code.

#include <iostream>#include <sstream>#include <fstream>#include <cstring>#include<string.h>#include <cstdlib>using namespace std;class Node {public:...
Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question