Question: 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



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
Get step-by-step solutions from verified subject matter experts
