- 1 -
1. (10 points) Suppose you are given a graph G=(V,E) with edge weights w(e) and a minimum
spanning tree T of G. Now, suppose a new edge {u,v} is added to G. Describe (in words) a
method for determining if T is still a minimum spanning tree for G.
Examine the path in T from u to v. If any vertex on this path has weight larger than that of the new
edge, then T is no longer an MST. We can modify T to obtain a new MST by removing the max
weight edge on this path and replacing it with the new edge.
Explain how your method can be implemented to run in O(n) time if both G and T are
provided as instances of the wgraph data structure.
Using the wgraph for T, we can do a recursive tree traversal in T, starting at vertex u. Once the
traversal reaches v, we “unwind” the recursion, and as we do so, we look for the max weight edge
along the u,v path.
The runtime for a tree traversal is O(n) and the required changes to T can be done in constant time.
Suppose that instead of a single edge, you are given a set of k new edges to add to G. For
small enough k it makes sense to apply your algorithm repeatedly in order to update the
MST, but if k is “too large”, it’s more efficient to re-compute the MST from scratch. How big
does k have to be (as a function of m and n) in order for this to be a better choice? Assume
that the MST is computed using Prim’s algorithm with a d-heap, where d=2.
When d=2, the running time for Prim’s algorithm is O(m log n), so if kn grows faster than this, it
makes sense to recompute from scratch. So, if k>(m/n) log n, it makes sense to recompute the MST.