CS331 Advanced Data Structures – Spring 2016 Due: April 18

advertisement
CS331 Advanced Data Structures – Spring 2016
Homework 8 – 40 points
Due: April 18
1. (10 points) Three safety inspectors – A, B and C – have been hired to check out three
different factories – X, Y and Z. Each inspector will inspect one of the factories, and since
you are paying them mileage from their homes to the factories, you want to minimize the
total distance traveled by the three inspectors. The chart below shows the distances involved:
A
B
C
X
12
10
8
Y
6
8
5
Z
11
12
9
Solve this problem using the algorithm described in class. Show the residual graph used at
each step (with the reduced costs), the shortest paths and augmenting path found in each
graph, and the resulting matching after each update.
2. (10 points) Consider the following street network:
{ 1
1
{ 1
4
{ 1
{ 2
2
1
{ 8
{
{
{ 5
{
@5
1
@
{
@{ 4
1
@
2
3
{
1
16
10
{ 3
{
9
{ 6
{
(a) Solve the Chinese Postman Problem on this grid, ignoring the edge costs, i.e., find a
cycle that uses all of the edges at least once which uses the minimum number of edges.
Justify your answer.
(b) Resolve the problem now using edge costs, i.e., find a cycle of minimum cost that uses
all of the edges at least once. Justify your answer.
3. (20 points) Write a program to solve the bitonic tour problem which determines not only the
bitonic tour value but outputs the tour as well. Use this to solve the three problems stored
in files btoura.dat, btourb.dat and btourc.dat in the folder ~bonomo\public\cs331\hw.
Each of these files starts with an integer n indicating the number of vertices in the graph, and
is followed by n lines giving the integer x, y coordinants of each vertex. I have also included
my solution for the first problem in the file btoura.sol.
Download