ALGORITHMS AND DATA STRUCTURES II PROGRAMMING ASSIGNMENT 2
Programming Assignment The town of NewVille was a very small town five years ago. There were very few roads that were good enough for cars, but it wasn’t a problem because there were very few cars in the town. Now the population has increased four times and there are so many cars that the mayor has to undertake a huge road construction project. His plan is to build on the existing road network, but to minimize cost he is thinking of improving only some of the roads. Of course he has to make sure that you can go from anywhere in the town to anywhere else by car. Given the road network, your job is to calculate the minimum budget required for this construction project. Input: An edge-weighted graph of n nodes (representing places in NewVille). The weights on the edges represent the cost of rebuilding that road. Output: The minimum cost/budget required for the construction project. A Java template has been provided containing an empty function mwst, which takes an two dimensional integer array G, that represents the graph, and returns the sum of the weights of the edges in a minimum spanning tree integer of G. Your task is to write the body of the mwst function. Your code is not required to check for incorrectly formed input data. You must use the provided Java template as the basis of your submission, and put your implementation inside the mwst function in the template. You may not change the name, return type or parameters of the mwst function. The main function in the template contains code to help you test your implementation by reading it from a file. A sample file is also provided. You may modify the main function or any other function, because your submission will be tested using a different main function. Only the contents of the mwst function and associated helper functions (if any) will be marked.