CS331 Advanced Data Structures – Spring 2016 Due: Mar. 21

advertisement
CS331 Advanced Data Structures – Spring 2016
Homework 5 – 45 points
Due: Mar. 21
1. (10 points) Solve the All Pairs Shortest Path problem using Floyd’s algorithm the following
graph. Show what the table looks like after each pass of the algorithm
7
v1
v2
@ 2
@ 4
8
@
@
4
@
@ 8
v3
v4
v5
@
@ 1
4
2
3
@
@
@
@
5
v7
v6
9
2. (10 points) Find a minimum spanning tree for the graph below, using both Prim’s and
Kruskal’s algorithm. For each, list the order in which edges are added to the tree. For
Prim’s algorithm, you should start at node D.
A
@ 8
7
@
4
@
B
C
@
@ 2
1
2
3
@
@
2
@ 2
@
D
E
F
@ 6
@
1
3
5
@
@
@ 3
@
G
H
@ 4
5
@
@
I
3. (25 points) Assume G is a graph with unique edge weights. Prove or disprove each of the
following statements (NOTE: your proof cannot use how Prim’s or Kruskal’s algorithm work).
(a) Let e be the minimum cost edge in G. Then e must be in any MCST.
(b) Let e be the second-most minimum cost edge in G. Then e must be in any MCST.
(c) Let e be the third-most minimum cost edge in G. Then e must be in any MCST.
(d) Let C be any cycle in G and let e be the maximum weight edge in C. Then no MCST
will contain e.
(e) Let C be any cycle in G and let e be the minimum weight edge in C. Then e must be
in any MCST.
Download