Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi I need help with java programming. I am given a list of cities in alphabetical order ( cities.txt ) and a list of pairs

Hi I need help with java programming. I am given a list of cities in alphabetical order (cities.txt) and a list of pairs of cities having a direct railroad connection between them (connections.txt). I need help with creating a program calledConnectedCitiesthat, using one of the union-find classes found in the algs4 package, builds a union-find object from these two files. Because you cannot store strings in a union-find object, use an array of strings for the cities and use a city's index in that array to represent it in the UF object.

After your main method does the above, it should then read in, line by line, pairs of cities from a file (checkconnections.txt) and indicate which pairs are connected based on the union-find object created above.

cities.txt:

Champaign

Chicago

Cincinnati

Cleveland

Detroit

Indianapolis

Joliet

Kankakee

Louisville

Madison

Milwaukee

Minneapolis

Nashville

SaintLouis

Springfield

Toledo

connections.txt:

Chicago Joliet

Chicago Kankakee

Louisville Champaign

Nashville Louisville

Louisville Cincinnati

Joliet Springfield

SaintLouis Springfield

Detroit Toledo

Cleveland Toledo

Madison Milwaukee

Minneapolis Madison

Chicago Milwaukee

Indianapolis Cincinnati

checkconnections.txt:

Chicago SaintLouis

Minneapolis Chicago

Minneapolis SaintLouis

Detroit Chicago

Joliet Cincinnati

Springfield Nashville

Nashville Cleveland

Nashville Cincinnati

Detroit Madison

Joliet Madison

Kankakee Minneapolis

Kankakee Indianapolis

Nashville Indianapolis

Minneapolis Indianapolis

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

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions