algorithm.
algorithm.
226
6 .
W E I G H T E D G R A P H A L G O R I T H M S
(c) Find the shortest path spanning tree rooted in A.
(d) Compute the maximum flow from A to H.
Minimum Spanning Trees
6-2. [3] Is the path between two vertices in a minimum spanning tree necessarily a
shortest path between the two vertices in the full graph? Give a proof or a coun-
terexample.
edges have the same weight). Is the path between a pair of vertices in a minimum
spanning tree necessarily a shortest path between the two vertices in the full graph?
Give a proof or a counterexample.
6-4. [3] Can Prim’s and Kruskal’s algorithm yield different minimum spanning trees?
Explain why or why not.
6-5. [3]
Does either Prim’s and Kruskal’s algorithm work if there are negative edge
weights? Explain why or why not.
6-6. [5] Suppose we are given the minimum spanning tree T of a given graph G (with n
vertices and m edges) and a new edge e = (u, v) of weight w that we will add to G.
Give an efficient algorithm to find the minimum spanning tree of the graph G + e.
Your algorithm should run in O(n) time to receive full credit.
6-7. [5] (a) Let T be a minimum spanning tree of a weighted graph G. Construct a new
graph G
by adding a weight of k to every edge of G. Do the edges of T form a
minimum spanning tree of G
? Prove the statement or give a counterexample.
(b) Let P =
{s, . . . , t} describe a shortest weighted path between vertices s and t
of a weighted graph G. Construct a new graph G
by adding a weight of k to every
edge of G. Does P describe a shortest path from s to t in G
? Prove the statement
or give a counterexample.
6-8. [5] Devise and analyze an algorithm that takes a weighted graph G and finds the
smallest change in the cost to a non-MST edge that would cause a change in the
minimum spanning tree of G. Your algorithm must be correct and run in polynomial
time.
6-9. [4] Consider the problem of finding a minimum weight connected subset T of edges
from a weighted connected graph
G. The weight of
T is the sum of all the edge
weights in T .
(a) Why is this problem not just the minimum spanning tree problem? Hint: think
negative weight edges.
(b) Give an efficient algorithm to compute the minimum weight connected subset
T .
6-10. [4]
Let G = (V, E) be an undirected graph. A set F
⊆ E of edges is called a
feedback-edge set if every cycle of G has at least one edge in F .
(a) Suppose that G is unweighted. Design an efficient algorithm to find a
minimum-size feedback-edge set.
6-3. [3] Assume that all edges in the graph have distinct edge weights (i.e., no pair of
6 . 7
E X E R C I S E S
227
(b) Suppose that G is a weighted undirected graph with positive edge weights.
Design an efficient algorithm to find a minimum-weight feedback-edge set.
Union-Find
6-12. [5]
Devise an efficient data structure to handle the following operations on a
weighted directed graph:
(a) Merge two given components.
(b) Locate which component contains a given vertex v.
(c) Retrieve a minimum edge from a given component.
6-13. [5]
Design a data structure that can perform a sequence of, m union and find
operations on a universal set of n elements, consisting of a sequence of all unions
followed by a sequence of all finds, in time O(m + n).
Shortest Paths
6-14. [3]
The single-destination shortest path problem for a directed graph seeks the
shortest path from every vertex to a specified vertex v. Give an efficient algorithm
to solve the single-destination shortest paths problem.
6-15. [3] Let G = (V, E) be an undirected weighted graph, and let T be the shortest-path
spanning tree rooted at a vertex v. Suppose now that all the edge weights in G are
increased by a constant number k. Is T still the shortest-path spanning tree from
Do'stlaringiz bilan baham: