Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Plase Write in JAVA with expelantation NYC Chicago LA Boston DC SF Dallas NYC Boston 2 NYC DC 2 NYC Chicago 7 Chicago Dallas 8

Plase Write in JAVA with expelantation

NYC Chicago LA Boston DC SF Dallas NYC Boston 2 NYC DC 2 NYC Chicago 7 Chicago Dallas 8 DC Dallas 10 Chicago SF 15 Chicago LA 15 SF LA 3 LA Dallas 10

6 9 0 1000 2400 stanbul 1 2800 3000 Konya 2 2400 2500 Ankara 3 4000 0 Hatay 4 4500 3800 Trabzon 5 6000 1500 Ar 0 1 0 3 1 2 1 4 2 4 2 3 2 5 3 5 4 5

image text in transcribed

image text in transcribedimage text in transcribed

In this part of the homework, you are to build high-speed railroad networks in the USA, so that traveling from NYC to DC in the United States becomes only 2 hours! To achieve that goal, assuming all cities are connected, you need to plan a railroad network and calculate the time between the cities, for which we need to solve the minimum spanning tree (MST) problem (by using Prim's or Kruskals algorithm). To make things easier we only care about the distances from a home city to all other cities. For this task, you must use your own implementation of graphs by taking inspiration from your textbook. You are not allowed to use any external library or .jar file. Sample input (sample_input1.txt) starts with a line of cities separated by blanks; the first city on that line is considered as the home (root node) city where you would grow your MST from. Each of the following lines is triple, where two cities and their distance (hours on planned high-speed rail). The distance is symmetric. NYC Chicago LA Boston DC SF Dallas NYC Boston 2 NYC DC 2 NYC Chicago 7 Chicago Dallas 8 DC Dallas 10 Chicago SF 15 Chicago LA 15 SF LA 3 LA Dallas 10 Here is the visualization according to sample input: DC Boston 2 NYC 10 7 00 Dallas Chicago 10 15 15 3 LA SE For the sample_input1.txt file, the sample output is given below. The output starts with a line of the total of the MST, followed by the lines is triple, where two cities and their distance. Please note that the output should follow a level-order traversal of the MST and within each level, use lexicographical order. For the sample_input1.txt file, the sample output is given below. The output starts with a line of the total of the MST, followed by the lines is triple, where two cities and their distance. Please note that the output should follow a level-order traversal of the MST and within each level, use lexicographical order. > java MST sample_input1.txt 32 NYC Boston 2 NYC DC 2 NYC Chicago 7 Chicago Dallas 8 Dallas LA 10 LA SF 3

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

DB2 11 The Ultimate Database For Cloud Analytics And Mobile

Authors: John Campbell, Chris Crone, Gareth Jones, Surekha Parekh, Jay Yothers

1st Edition

ISBN: 1583474013, 978-1583474013

More Books

Students also viewed these Databases questions