Академический Документы
Профессиональный Документы
Культура Документы
We dene the potential function as twice the distance of i from the largest power of 2 that is at most i, i.e. (Di ) = 2 i 2
log2 i
.
n i=1 ci
n i=1 ci .
We just
n i=1 ci
3. Describe an algorithm for nding a spanning tree with minimal weight containing a specied acyclic (cycle-free) set of edges A in a connected weighted undirected graph. Solution: We just run Kruskals algorithm, but instead of starting with an empty set of edges, we start with the edge set A given. (20 points) 4. Problem 23-1 a. on page 638. Solution: To see that the minimum spanning tree (MST) is unique, observe that since the graph is connected and all edge weights are distinct, then there is a unique light edge crossing every cut. But then if we consider two MSTs T and T , we will show that every edge of T is also an edge of T (and vice versa) and thus T is the same as T . Consider an edge (u, v) T . If we remove (u, v) from T , then T becomes disconnected, resulting in a cut (S, V \ S). The edge (u, v) is a light edge crossing this cut. T also has a light edge (x, y) crossing this cut. Because the light edge crossing this cut is unique, the edges (u, v) and (x, y) are the same, and thus (u, v) is an edge of T . To see that the second-best MST need not be unique, here is a weighted, undirected graph G on 4 vertices {v1 , v2 , v3 , v4 } with a unique MST T of weight 7 and two second-best MSTs T1 and T2 of weight 8: E(G) = {(v1 , v2 ), (v1 , v3 ), (v2 , v3 ), (v2 , v4 ), (v3 , v4 )}, where w(v1 , v2 ) = 3, w(v1 , v3 ) = 2, w(v2 , v3 ) = 1, w(v2 , v4 ) = 4, w(v3 , v4 ) = 5. Then T = {(v1 , v3 ), (v2 , v3 ), (v2 , v4 )}, T1 = {(v1 , v2 ), (v2 , v3 ), (v2 , v4 )} and T2 = {(v1 , v3 ), (v2 , v3 ), (v3 , v4 )}. (20 points) 5. Exercise 24.3-5 on page 663. Solution: Here is a simple example for a directed graph for which Dijkstras algorithm could relax the edges of a shortest path out of order. The graph has vertices s, x, y, z and edges (s, x), (x, y), (y, z), (s, y) and let every edge have weight 0. Dijkstras algorithm could relax edges in the order (s, y), (s, x), (y, z), (x, y). The graph has two shortest paths 2
from s to z: (s, x, y, z) and (s, y, z), both with weight 0. The edges on the shortest path (s, x, y, z) are relaxed out of order, because (x, y) is relaxed after (y, z). (20 points)