Develop a cpp program that reads an input data set

Assignment Help C/C++ Programming
Reference no: EM131884175

Project Assignment

Program Description

You will 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 cities with its state, population, and geo-location. 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 open addressing, double-hashing) needs to be created. Each slot of your hash table should be a pointer of the class called City which you will be creating to store each city's name, state, population, and its geo-location (do not store double-quotes " used for geo- location), and a number of collisions. Initially each pointer should be NULL.

2. Then by reading each city 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. You need to specify your hash functions that will be used, i.e., h(k,i), and h_1(k) and h_2(k) using each city name as its key value.

The following shows an example of such data for cities:

AL,Mobile,195111,"(30.67762486480, -88.1184482714)"
AK,Anchorage,291826,"(61.14986873100, -149.111113424)"
AZ,Phoenix,1445632,"(33.57241386950, -112.088995222)"
AZ,Scottsdale,217385,"(33.68724936510, -111.865085877)"
AR,Fayetteville,73580,"(36.07121173120, -94.1659600436)"
AR,Fort Smith,86209,"(35.34916926360, -94.3696317306)"
AR,Jonesboro,67263,"(35.82081215380, -90.6794991686)"
CA,Anaheim,336265,"(33.83890769960, -117.857613481)"

3. After the line "InsertionEnd", your program needs to print out the content of your hash table. Then a user will enter a number of commands.

4. Each command will be "hash_display", "hash_search", or "hash_max_population".

Hash_Display command:

With "hash_display" command, your program needs to display the content of your hash table by listing the content of each index in the following format, by specifying their number of collisions. If a slot if empty, print out "none" for strings and "--" for integers:

index

state

city name

collisions

population

geolocation

0

none

none

--

--

none

1

CO

Denver

0

600158

(39.76202837430, -104.876365322)

2

DC

Washington

0

601723

(38.90992414260, -77.0147205666)

3

none

none

--

--

none

4

AK

Anchorage

0

291826

(61.14986873100, -149.111113424)

5

none

none

--

--

none

6

IN

Bloomington

1

80405

(39.16374582210, -86.5257124351)

7

ID

Boise City

0

205671

(43.59843438970, -116.230885189)

8

CA

Burbank

0

103340

(34.18797996050, -118.323429032)

9

CO

Boulder

2

97385

(40.02755104940, -105.251517760)

Hash_Search command:
Hash_Search command will have the format of:

hash_search,CT,Hartford

where the word "hash_search" is followed by state and a city name, and they are separated by commas.

After the hash_search command is entered, the program should search for the city and its state that matches those data fields, and if it is found, display their information with their population and geolocation as:

The city Hartford of CT with its population of 124775 and its geolocation of (41.76607064190, -72.6834012389) was found
If not found, display a message using the following format: The city Topeka of KS was not found Hash_Max_Population command:
Hash_Max_Population command will have the format of:

hash_max_population

After the hash_max_population command is entered, the program should search for the city with the maximum population, and if it is found, the program needs to display a message using the following format using their information:

The city Chicago of IL has the highest population of 2695598

If the hash table is empty:

There is no city stored in the hash table

Design Requirements:

You should create a hash table with open addressing using double hashing. You also need to define hash_display, hash_insert, hash_search, and hash_max_population functions for the hash table.

Implementation/Documentation Requirements:

• You need implement this program using C++ and it has to read from the standard input (from a keyboard).

• Your program needs to compile and execute in general.asu.edu.

• You need to create a class or a struct City containing, state, city name, population, geolocation, and collisions.

• You need to define hash_display, hash_insert, hash_search, and hash_max_population functions (name them "hash_display", "hash_insert", "hash_search", "hash_max_population", for your hash table, and a hash function h, h1, and h2.

• Your code should be well documented and commented.

• At the top of your driver file, within a comment, write your hash analysis -- how did you come up with your hash function? Was the number of collisions what you expected? Did your hash function work well? If you had to change your function to reduce the number of collisions, how did you change it?

• You must use the provided data sets.

• Also you are not allowed to use any predefined data structures (such as ones in the library in C++, etc.) except arrays and strings, you need to build your own data structures and operations associated with them (such as insert or search).

• Copying any codes from other people's programs is considered to be cheating and will lead to a report to the Dean and you will be penalized. Also check the rules stated in the syllabus of the course regarding the academic integrity

What to turn in:

submit a zip file containing the following:

1. one or more files of your well documented C++ source code (with a file extension .cpp or .h) implementing the commands required, your hash table.

2. A Makefile that compiles your program to an executable named "cse310project1" on the Linux machine general.asu.edu. Our TA will write a script to compile and run all student submissions on general.asu.edu; therefore executing the make command must produce the executable file "cse310project1" in the same folder as your source code files. After such cse310project1 file is produced, then we should be able to execute your program using the command:

./cse310project1 < sampleinput.txt

where "sampleinput.txt" is a file name, but we should be able to use a file with a different name with a content in the format specified in the project statement.

Your program must read from a keyboard, not a file.

Error Handling

Your program will be tested with other input besides the sample input given, thus is expected to be robust.

Attachment:- Sample-Input-and-Output.rar

Reference no: EM131884175

Questions Cloud

Why might management opt for other than economical choice : Teloxy Engineering has received a one-time contract to design. Strategically thinking, why might management opt for other than the most economical choice?
What is the internal rate of return? of this? opportunity : What is the internal rate of return? (IRR) of this? opportunity?
Should the bank go long or short on the futures contracts : Dudley Savings Bank wishes to take a position in Treasury bond futures contracts, Should the bank go long or short on the futures contracts?
Explain key elements of disaster recovery plan to be used : Explain the key elements of the Disaster Recovery Plan to be used in case of a disaster and the plan for testing the DRP.
Develop a cpp program that reads an input data set : You will 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.
Create a board matrix of current board members : Create a board matrix of current board members . What is the nature of the relationship between the board and the rest of the staff
The cash flows are expected to be as follows : John Keene recently invested $2250 in a project that is promising to return 10 percent per year. the cash flows are expected to be as follows:
Discuss how one personal value system can shape the teaching : Discuss how one's personal value system, attitudes, stereotypes, and prejudices can shape the teaching and learning process.
Do we as a church allow political figure campaign in church : Do we, as a church, allow a political figure campaign in our church? Some say yes and some say no. What do you do?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd