Docsity

Algorithms and Graphs: Homework III Solutions, Assignments of Computer Science

Toggle sidebar
bg1
Design and Analysis of Algorithms
Graph Algorithms
May 5, 2000
Homework III: Turn in the solutions to problems 4 and 12 on May 23rd, 2000 in class. No late or early
submissions.
1. Problem 23.2-7, Page 476; (CLR)
2. Problem 23-2, Page 495; (CLR)
3. Problem 23-3, Page 496; (CLR)
4. Problem 24-1, Page 511; (CLR)
5. Problem 24.2-7, Page 510; (CLR)
6. Problem 24.2-8, Page 510; (CLR)
7. Problem 25.3-6, Page 536; (CLR)
8. Problem 25.2-5, Page 532; (CLR)
9. Problem 25-1, Page 545; (CLR)
10. Problem 25-2, Page 546; (CLR)
11. Problem 25-3, Page 546; (CLR)
12. If
P
is a path in a weighted graph
G
,let
maxweight
(
P
)
be the maximum of all the weights of the
edges in
P
.
Give a polynomial-time algorithm to solve the following problem:
Given an undirected graph whose edges have positive integral weights, and two distinct vertices
s
and
t
, among all
s
,
t
paths
P
find one for which
maxweight
(
P
)
is minimized. (This is a bottleneck
shortest
s
,
t
path.)
13. Let
G
be a connected graph whose edges have positive integral weights. A minimum product spanning
tree is a spanning tree in
G
, for which the product of the edge weights in minimized.
Give a polynomial-time algorithm that finds a minimum product spanning trees in a given connected,
weighted graph. Hint: Think logarithms, but you cannot actually use them in the final algorithm, since
computers cannot exactly manipulate irrational numbers like logarithms.
14. Prove that a graph is bipartite if and only if it has no odd cycles.
15. Give an algorithm running in time
O
(
m
+
n
)
for finding the distance from
s
to every other vertex in
an undirected graph, all of whose edges have weight 1 or 2.
1
pf3

Partial preview of the text

Download Algorithms and Graphs: Homework III Solutions and more Assignments Computer Science in PDF only on Docsity!

Design and Analysis of Algorithms

Graph Algorithms

May 5, 2000

Homework III: Turn in the solutions to problems 4 and 12 on May 23rd, 2000 in class. No late or early submissions.

  1. Problem 23.2-7, Page 476; (CLR)
  2. Problem 23-2, Page 495; (CLR)
  3. Problem 23-3, Page 496; (CLR)
  4. Problem 24-1, Page 511; (CLR)
  5. Problem 24.2-7, Page 510; (CLR)
  6. Problem 24.2-8, Page 510; (CLR)
  7. Problem 25.3-6, Page 536; (CLR)
  8. Problem 25.2-5, Page 532; (CLR)
  9. Problem 25-1, Page 545; (CLR)
  10. Problem 25-2, Page 546; (CLR)
  11. Problem 25-3, Page 546; (CLR)
  12. If P is a path in a weighted graph G, let maxw eig ht(P ) be the maximum of all the weights of the edges in P. Give a polynomial-time algorithm to solve the following problem: Given an undirected graph whose edges have positive integral weights, and two distinct vertices s and t, among all s t paths P find one for which maxw eig ht(P ) is minimized. (This is a bottleneck shortest s t path .)
  13. Let G be a connected graph whose edges have positive integral weights. A minimum product spanning tree is a spanning tree in G, for which the product of the edge weights in minimized. Give a polynomial-time algorithm that finds a minimum product spanning trees in a given connected, weighted graph. Hint: Think logarithms, but you cannot actually use them in the final algorithm, since computers cannot exactly manipulate irrational numbers like logarithms.
  14. Prove that a graph is bipartite if and only if it has no odd cycles.
  15. Give an algorithm running in time O (m + n) for finding the distance from s to every other vertex in an undirected graph, all of whose edges have weight 1 or 2.
  1. Look at problem one to find the definition of a matching. A maximum matching is one of maximum cardinality. Prove that the following algorithm correctly finds a maximum matching in a forest F : If F has no edges, output the empty set and halt. Otherwise, let v be a leaf in F , let u be its neighbor and let e = fu; v g. Let F 0 be the forest obtained by deleting both v and u (and all incident edges) from F. Recursively find a maximum matching M 0 in F 0 , and output M 0 [ feg.
  2. Consider bipartite graphs of the following special form:
    • the vertex set is fx 1 ; ::xn g (boys), fy 1 ; :::yn g (girls).
    • if (xi ; yj ) is an edge, there are no edges of the form (xu ; yv ) with both u > i and v < j. A matching is a set of edges, no two of wich are incident on the same vertex. Design an algorithm that finds a maximum cardinality matching in linear time.
  3. Edge-disjoint paths

a Given an undirected graph G = V ; E and two distinguished nodes, s and t, describe an algorithm that finds a maximum-sized set of edge-disjoint paths from s to t. (We say that two paths are edg e disj oint if they donโ€™t share a common edge, even though they are allowed to go through the same vertex.) Give a time analysis for your algorithm in terms of jV j and jE j. b Given a solution to (a), suppose we add one more edge to the graph. Give an efficient algorithm for updating the solution. Give a time analysis for your algorithm in terms of jV j and jE j. (Your algorithm should be significantly faster than redoing the entire problem from scratch.)

  1. Special cases of shortest paths

Problem You need to solve all pairs longest paths ( i.e. total delays) for a VLSI application. The input graphs are D AGs where each node has in-degree at most 2. The edge lengths are all either 1 or

  1. What algorithm and which data structures would you use? What is the time complexity of the algorithm for these instances?
  2. One-Way streets

Problem A city currently has only two-way streets in its downtown. It wants to make all of the streets one-way, while keeping any location reachable from any other location. Formally, an instance of the problem is an undirected graph. A solution is a directed graph where each edge in the undirected graph appears in exactly one direction. The constraint is that the solution must be strongly connected. Give the most efficient algorithm you can for the problem of finding a solution that is strongly connected or showing that it is impossible.

  1. Always Non-negative Path

Problem Leg G be an n-node directed graph whose edges are labelled either -1 or 1. A path e 1 ; : : : et in G is al w ay snon-neg ativ e if the sum of the weights of e 1 up to ei is non-negative for all 1  i  t. A source s and a destination s^0 are given as inputs. Give an algorithm to decide whether there is an always non-negative path from s to s^0.

  1. Broadcast Times for a Tree

Problem Let T be a rooted binary tree whose edges are given positive real weights, representing messag edel ay times. For a node x 2 T , define the br oadcasttime for x to be the maximum over y 2 T of the weighted distance in T between x and y. (In other words, the broadcast time is the time before a message originatin at x is received by every other processor y .) Give an efficient algorithm to compute all the broadcast times for nodes in T simultaneously.