Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are required to develop a C++ program that reads an input data set consisting of four parts (a lot of the coding is already

You are required to develop a C++ program that reads an input data set consisting of four parts (a lot of the coding is already done in Assignment4.cpp,LinkedList.h and Hash.h files below):

a) The first part is a hash table size requested by a user.

b) The second part is a list of students, this part will end with the line InsertionEnd

c) The third part is a number of commands to follow

d) The forth part is a list of commands.

1. After reading in a hash table size (reresented by an integer), a hash table of the size (collision resolving by chaining) needs to be created. Each slot of your hash table should be a link list of nodes where each node represents one Student. Initially all linked lists should be empty.

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

Each student data will be in one line and will contain the following information which are separated by commas:

name, gender, inClass_or_onLine, major, campus, status, address, city

The following shows an example of such data for students:

John Smith,M,InClass,Computer Science,Tempe,Freshman,123 Whatever St.,Chandler Mary Johnson,F,InClass,Business,Tempe,Junior,213 Whatever St.,Chandler Carole Almenda,F,InClass,Computer Science,Polytech,Sophomore,111 Mickey Mouse Ave.,Tempe Natalie Parkson,F,InClass,Psychology,Tempe,Freshman,123 Main Ave.,Tempe Adriean Santoros,F,InClass,Psychology,Tempe,Freshman,22 Linda Dr.,Gilbert Tammy Barnes,M,Online,Business,Tempe,Senior,22 Linda Dr.,Seattle Jason Brown,M,InClass,Computer Science,Polytech,Freshman,123 University Dr.,Tempe Roger Clark,M,InClass,Business,Tempe,Junior,213 Whatever St.,Chandler

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

4. Each command will be in one of the three forms: hashDisplay, hashSearch, or hashDelete.

hashDisplay command:

With hashDisplay command, your program needs to display the content of your hash table by listing the content of each linked list in the following format,

By specifying the index of each slot of the hash table and their linked list size (if a linked list is empty, it should print out The list is empty.

Then print out each linked lists elements one-by-one.

hashSearch command: hashSearch command will have the format of:

hashSearch,name,gender,major,address

where the word hashSearch is followed by name,gender,major,address of a student and the data is separated by commas. A real example of such command can be:

hashSearch,John Smith,M,Computer Science,123 Whatever St.

After the hashSearch command is entered, the program should search for a student that matches those data fields, and if it is found, display the following information:

John Smith in Computer Science major, on Tempe campus is found.

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

Lily Guy with Computer Science major, live at 123 Main Ave. is not found.

hashDelete command: hashDelete command will have the format of:

hashDelete,name,gender,major,address

where the word hashDelete is followed by name,gender,major,address of a student and the data is separated by commas. A real example of such command can be:

hashDelete,Roger Clark,M,Business,213 Whatever St.

After the hashDelete command is entered, the program should search for a student 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:

Roger Clark in Business major, on Tempe campus is deleted.

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

John Smith with Computer Science major, live at 12 Main Ave. is not found.

2. Design Requirements

You should create a hash table with collision-resolving-by-chaining (an array of linked lists). Please specify your hash function h(k) clearly. The key for each student will be a string made by appending their name, gender, major, and address. For instance, for the student with the information:

John Smith,M,InClass,Computer Science,Tempe,Freshman,123 Whatever St.,Chandler

the key should be John SmithMComputer Science123 Whatever St.

You also need to define hashInsert, hashDelete, and hashSearch functions for the hash table, and define insert, deleteStudent, search functions for the linked list. Please have comments to clearly identify these functions in your code.

Example: Input1.txt

6 John Smith,M,InClass,Computer Science,Tempe,Freshman,123 Whatever St.,Chandler Mary Johnson,F,InClass,Business,Tempe,Junior,213 Whatever St.,Chandler Carole Almenda,F,InClass,Computer Science,Polytech,Sophomore,111 Mickey Mouse Ave.,Tempe Natalie Parkson,F,InClass,Psychology,Tempe,Freshman,123 Main Ave.,Tempe Adriean Santoros,F,InClass,Psychology,Tempe,Freshman,22 Linda Dr.,Gilbert Tammy Barnes,M,Online,Business,Tempe,Senior,22 Linda Dr.,Seattle Jason Brown,M,InClass,Computer Science,Polytech,Freshman,123 University Dr.,Tempe Roger Clark,M,InClass,Business,Tempe,Junior,213 Whatever St.,Chandler InsertionEnd 8 hashDisplay hashDelete,Natalie Parkson,F,Psychology,123 Main Ave. hashSearch,John Smith,M,Computer Science,123 Whatever St. hashSearch,Lily Guy,F,Computer Science,123 Main Ave. hashDelete,Jason Brown,M,Computer Science,123 University Dr. hashSearch,Roger Clark,M,Business,213 Whatever St. hashDelete,Roger Clark,M,Business,213 Whatever St. hashDisplay

Example: Output1.txt

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

index: 0, linked list size: e The list is empty index: 1, linked list size: 4 Roger Clark Name Gender: inClassOrOnLine: InClass Major Campus: Address: City: Business Tempe 213 Whatever St. Chandler Name Gender: inClassOrOnLine: InClass Major Campus: Address: City: Jason Brown Computer Science Polytech 123 University Dr. Tempe Mary Johnson Name Gender: inClassOrOnLine: InClass Major: Campus: Address: City: Business Tempe 213 Whatever St. Chandler John Smith Name Gender: inClassOrOnLine: InClass Major: Campus: Address: City: Computer Science Tempe 123 Whatever St. Chandler index: 2, linked list size: 2 Name Gender: inClassOrOnLine: Online Major: Campus: Address: Tammy Barnes Business Tempe 22 Linda Dr Seattle index: 0, linked list size: e The list is empty index: 1, linked list size: 4 Roger Clark Name Gender: inClassOrOnLine: InClass Major Campus: Address: City: Business Tempe 213 Whatever St. Chandler Name Gender: inClassOrOnLine: InClass Major Campus: Address: City: Jason Brown Computer Science Polytech 123 University Dr. Tempe Mary Johnson Name Gender: inClassOrOnLine: InClass Major: Campus: Address: City: Business Tempe 213 Whatever St. Chandler John Smith Name Gender: inClassOrOnLine: InClass Major: Campus: Address: City: Computer Science Tempe 123 Whatever St. Chandler index: 2, linked list size: 2 Name Gender: inClassOrOnLine: Online Major: Campus: Address: Tammy Barnes Business Tempe 22 Linda Dr Seattle

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mastering Influxdb Database A Comprehensive Guide To Learn Influxdb Database

Authors: Cybellium Ltd ,Kris Hermans

1st Edition

B0CNGGWL7B, 979-8867766450

More Books

Students also viewed these Databases questions