Chapter23
Michelle Bodnar,Andrew Lohr
April12,2016
Exercise23.1-1
Suppose that A is an empty set of edges.Then,make any cut that has(u,v) crossing it.Then,since that edge is of minimal weight,we have that(u,v)is a light edge of that cut,and so it is safe to add.Since we add it,then,once wefinish constructing the tree,we have that(u,v)is contained in a minimum spanning tree.
Exercise23.1-2
Let G be the graph with4vertices:u,v,w,z.Let the edges of the graph be (u,v),(u,w),(w,z)with weights3,1,and2respectively.Suppose A is the set {(u,w)}.Let S=A.Then S clearly respects A.Since G is a tree,its minimum spanning tree is itself,so A is trivially a subset of a minimum spanning tree. Moreover,every edge is safe.In particular,(u,v)is safe but not a light edge for the cut.Therefore Professor Sabatier’s conjecture is false.
Exercise23.1-3
Let T0and T1be the two trees that are obtained by removing edge(u,v) from a MST.Suppose that V0and V1are the vertices of T0and T1respectively. Consider the cut which separates V0from V1.Suppose to a contradiction that there is some edge that has weight less than that of(u,v)in this cut.Then,we could construct a minimum spanning tree of the whole graph by adding that edge to T1∪T0.This would result in a minimum spanning tree that has weight less than the original minimum spanning tree that contained(u,v).
Exercise23.1-4
Let G be a graph on3vertices,each connected to the other2by an edge, and such that each edge has weight1.Since every edge has the same weight, every edge is a light edge for a cut which it spans.However,if we take all edges we get a cycle.
1
Exercise23.1-5
Let A be any cut that causes some vertices in the cycle on once side of the cut,and some vertices in t
he cycle on the other.For any of these cuts,we know that the edge e is not a light edge for this cut.Since all the other cuts wont have the edge e crossing it,we won’t have that the edge is light for any of those cuts either.This means that we have that e is not safe.
Exercise23.1-6
Suppose that for every cut of the graph there is a unique light edge crossing the cut,but that the graph has2spanning trees T and T .Since T and T are distinct,there must exist edges(u,v)and(x,y)such that(u,v)is in T but not T and(x,y)is in T but not T.Let S={u,x}.There is a unique light edge which spans this cut.Without loss of generality,suppose that it is not(u,v). Then we can replace(u,v)by this edge in T to obtain a spanning tree of strictly smaller weight,a contradiction.Thus the spanning tree is unique.
For a counter example to the converse,let G=(V,E)where V={x,y,z} and E={(x,y),(y,z),(x,z)}with weights1,2,and1respectively.The unique minimum spanning tree consists of the two edges of weight1,however the cut where S={x}doesn’t have a unique light edge which crosses it,since both of them have weight1.
Exercise23.1-7
First,we show that the subset of edges of minimum total weight that con-nects all the vertices is a tree.To see this,suppose not,that it had a cycle. This would mean that removing any of the edges in this cycle would mean that the remaining edges would still connect all the vertices,but would have a total weight that’s less by the weight of the edge that was removed.This would con-tradict the minimality of the total weight of the subset of vertices.Since the subset of edges forms a tree,and has minimal total weight,it must also be a minimum spanning tree.
To see that this conclusion is not true if we allow negative edge weights,we provide a construction.Consider the graph K3with all edge weights equal to −1.The only minimum weight set of edges that connects the graph has total weight−3,and consists of all the edges.This is clearly not a MST because it is not a tree,which can be easily seen because it has one more edge than a tree on three vertices should have.Any MST of this weighted graph must have weight that is at least-2.
Exercise23.1-8
Suppose that L is another sorted list of edge weights of a minimum span-ning tree.If L =L,there must be afirst edge(u,v)in T or T which is of smaller weight than the corresponding edge(x,y)in the other set.Without
2
loss of generality,assume(u,v)is in T.Let C be the graph obtained by adding (u,v)to L .Then we must have introduced a cycle.If there exists an edge on that cycle which is of larger weight than(u,v),we can remove it to obtain a tree C of weight strictly smaller than the weight of T ,contradicting the fact that T is a minimum spanning tree.Thus,every edge on the cycle must be of lesser or equal weight than(u,v).Suppose that every edge is of strictly smaller weight.Remove(u,v)from T to disconnect it into two components.There must exist some edge besides(u,v)on the cycle which would connect these,and since it has smaller weight we can use that edge instead to create a spanning tree with less weight than T,a contradiction.Thus,some edge on the cycle has the same weight as(u,v).Replace that edge by(u,v).The corresponding lists L and L remain unchanged since we have swapped out an edge of equal weight, but the number of edges which T and T have in common has increased by1. If we continue in this way,eventually they must have every edge in common, contradicting the fact that their edge weights differ somewhere.Therefore all minimum spanning trees have the same sorted list of edge weights.
Exercise23.1-9
Suppose that there was some cheaper spanning tree than T .That is,we have that there is some T  so that w(T  )<w(T ).Then,let S be the edges in T but not in T .We can then construct a minimum spanning tree of G by considering S∪T  .This is a spanning tree since S∪T is,and T  makes all the vertices in V connected just like T does.However,we have that w(S∪T  )=w(S)+w(T  )<w(S)+w(T )=w(S∪T )=w(T).This means that we just found a spanning tree that has a lower total weight than a minimum spanning tree.This is a contradiction,and so our assumption that there was a spanning tree of V cheaper than T must be false.
Exercise23.1-10
Suppose that T is no longer a minimum spanning tree for G with edge weights given by w .Let T be a minimum spanning tree for this graph.Then we have we have w (T )<w(T)−k.Since the edge(x,y)may or may not be in T we have w(T )≤w (T )+k<w(T),contradicting the fact that T was minimal under the weight function w.
Exercise23.1-11
If we were to add in this newly decreased edge to the given tree,we would be creating a cycle.Then,if we were to remove any one of the edges along this cycle,we would still have a spanning tree.This m
eans that we look at all the weights along this cycle formed by adding in the decreased edge,and remove the edge in the cycle of maximum weight.This does exactly what we want since we could only possibly want to add in the single decreased edge,and then,from there we change the graph back to a tree in the way that makes its total weight
3
minimized.
Exercise23.2-1
Suppose that we wanted to pick T as our minimum spanning tree.Then,to obtain this tree with Kruskal’s algorithm,we will order the edgesfirst by their weight,but then will resolve ties in edge weights by picking an edgefirst if it is contained in the minimum spanning tree,and treating all the edges that aren’t in T as being slightly larger,even though they have the same actual weight. With this ordering,we will still befinding a tree of the same weight as all the minimum spanning trees w(T).However,since we prioritize the edges in T,we have that we will pick them over any other edges that may be in other minimum spanning trees.
Exercise23.2-2
At each step of the algorithm we will add an edge from a vertex in the tree created so far to a vertex not in the tree,such that this edge has minimum weight.Thus,it will be useful to know,for each vertex not in the tree,the edge from that vertex to some vertex in the tree of minimal weight.We will store this information in an array A,where A[u]=(v,w)if w is the weight of(u,v) and is minimal among the weights of edges from u to some vertex v in the tree built so far.We’ll use A[u].1to access v and A[u].2to access w.
Algorithm1PRIM-ADJ(G,w,r)
Initialize A so that every entry is(NIL,∞)
T={r}
for i=1to V do
if Adj[r,i]=0then
A[i]=(r,w(r,i))
end if
end for
for each u∈V−T do
k=min i A[i].2
T=T∪{k}
k.π=A[k].1
for i=1to V do
if Adj[k,i]=0and Adj[k,i]<A[i].2then
A[i]=(k,Adj[k,i])
end if
end for
end for
minimal
Exercise23.2-3
4
Prim’s algorithm implemented with a Binary heap has runtime O((V+ E)lg(V)),which in the sparse case,is just O(V lg(V)).The implementation with Fibonacci heaps is O(E+V lg(V))=O(V+V lg(V))=O(V lg(V)).So, in the sparse case,the two algorithms have the same asymptotic runtimes.
In the dense case,we have that the binary heap implementation has runtime O((V+E)lg(V))=O((V+V2)lg(V))=O(V2lg(V)).The Fibonacci heap implementation however has a runtime of O(E+V lg(V))=O(V2+V lg(V))= O(V2).So,in the dense case,we have that the Fibonacci heap implementation is asymptotically faster.
The Fibonacci heap implementation will be asymptotically faster so long as E=ω(V).Suppose that we have some function that grows more quickly than linear,say f,and E=f(V).The binary heap implementation will have runtime O((V+E)lg(V))=O((V+f(V))lg(V))=O(f(V)lg(V)).However, we have that the runtime of the Fibonacci heap implementation will have run-time O(E+V lg(V))=O(f(V)+V lg(V)).This runtime is either O(f(V))or O(V lg(V))depending on if f(V)grows more or less quickly than V lg(V)re-spectively.In either case,we have that the runtime is faster than O(f(V)lg(V)).
Exercise23.2-4
If the edge weights are integers in the range from1to|V|,we can make Kruskal’s algorithm run in O(Eα(V))time by using counting sort to sort the edges by weight in linear time.I would take the same approach if the edge weights were integers bounded by a constant,since the runtime is dominated by the task of deciding whether an edge joins disjoint forests,which is independent of edge weights.
Exercise23.2-5
If there the edge weights are all in the range1,...,|V|,then,we can imagine adding the edges to an array of lists,where the edges of weight i go into the list in index i in the array.Then,to decrease an element,we just remove it from the list currently containing it(constant time)and add it to the list corresponding to its new value(also constant time).To extract the minimum wight edge,we maintain a linked list among all the indices that contain non-empty lists,which can also be maintained with only a constant amount of extra work.Since all of these operations can be done in constant time,we have a total runtime O(E+V).
If the edge weights all lie in some bounded universe,suppose in the range 1to W.Then,we can just vEB tree structure given in chapter20to have the two required operations performed in time O(lg(lg(
W))),which means that the total runtime could be made O((V+E)lg(lg(W))).
Exercise23.2-6
For input drawn from a uniform distribution I would use bucket sort with
5

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。