"Mission Accomplished". George W. Bush, May 1, 2003.
Due: Wednesday, May 13 at 2200 hours.
Hand out: sample input, my reference program
Hand in:
readme.pdf: a PDF file briefly
Note: This is a group homework. You should work in groups of two. Only
one person from each group shall hand in all the files.
On the first two lines
of Makefile, write each team member's
email username at ucdavis.edu, last name, and first name (one person per line) as comments.
For example:
# bsimpson; Simpson, Bart
# mburns; Burns, Montgomery
If you fail to follow this specification, you will lose points.
A long time ago in a galaxy far, far away, the country Miraq had n cities and m old roads, where each road connected a pair of cities. Due to the treacherous mountains, there was no road or even path between some cities (i.e., some cities were unreachable from others). During Operation Miraq Freedom, which spread democracy across Miraq like wildfire in summer Southern California, the Mamerican forces evaporated all the old roads in Miraq. As the Commanding General of the Mamerican forces, you are in charge of Operation Miraq Reconstruction, which will build new roads in Miraq subject to the following constraints:
Define a region to be a set of cities that will be reachable from one another via some new roads. For each region, you will select as the capital the city that minimizes the maximum distance (via new roads) from any city (in the region) to the capital.
Find the algorithms of the best asymptotic running times.
You may NOT use STL classes except the string class.
Input: Read input from cin. The input contains the number of cities (n), the number of old roads, and a series of old roads where each road consists of its two terminal cities and its distance. Each city is represented by a unique integer from 0 to n-1. Each distance is represented by an integer. Here is an example input.
You need not handle errors in input.
Output:
Number of regions: 2
Region
diff my_output your_outputHints: You probably need to implement union-find, an O(n log n) sorting, min heap, minimum cost spanning tree, Adjacency Multilist representation of graphs (Section 6.1.3.3 in the textbook). You will also need to invent an algorithm not in the textbook.
Trivia: For the etymology of the city and country names in this story, watch 2007 Mypods and Boomsticks.