Connected Components - Efficient Algorithms and Intractable Problems - Exams, Exams of Algorithms and Programming

Main points of this exam paper are: Connected Components, Strongly Connected, Earliest Nu, Topologically, Topologically Sort, Another Pass, Number Assigned, Numbers Generated, Post Numbers, Partial Credit

Typology: Exams

2012/2013

Uploaded on 04/02/2013

sushmi_98
sushmi_98 🇮🇳

4.5

(4)

51 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 170 First Midterm 15 Feb 2001
Problem 1 (20 Points)
a)
Run the Strongly Connected Components (SCC) algorithm on the following graph. Show
the pre and post numbers for both passes of DFS. Where there are several choices of
vertex to start at or edges to follow, go to the vertex that occurs earliest numerically.
b)
How can we topologically sort the SCCs without running another pass of DFS? Assume
you still have all the information generated by the SCC algorithm available, including pre
and post numbers generated during each pass of DFS, and the SCC number assigned to
each vertex.
pf3
pf4
pf5

Partial preview of the text

Download Connected Components - Efficient Algorithms and Intractable Problems - Exams and more Exams Algorithms and Programming in PDF only on Docsity!

Problem 1 (20 Points)

a) Run the Strongly Connected Components (SCC) algorithm on the following graph. Show the pre and post numbers for both passes of DFS. Where there are several choices of vertex to start at or edges to follow, go to the vertex that occurs earliest numerically.

b) How can we topologically sort the SCCs without running another pass of DFS? Assume you still have all the information generated by the SCC algorithm available, including pre and post numbers generated during each pass of DFS, and the SCC number assigned to each vertex.

Problem 2 (24 Points)

True or False? No explanation required except for partial credit. Each correct answer is worth 2 points, but 2 points will be subtracted for each wrong answer, so answer only if you are reasonable certain.

  1. Let G be a directed graph. The Bellman-Ford algorithm will find the longest path (if it is finite, or report if it is not) from the start vertex s to any other vertex v in graph if we negate all the edges weights W(e) before running the algorithm.
  2. Let G be a directed graph with positive edge weights W(e). Let Wmax = maxe W(e) be the maximum edge weight. Djikstra’s algorithm will find the longest path from the start vertex s to any other vertex v in a graph if we replace all the edges weights W(e) by the new positive weights 1 + Wmax – W(e) before running the algorithm.
  3. e c√ν^ is O(e√ν^ ) for all c >0.
  4. n2 sin(n)/log (n)^ is O(n 2 ).
  5. After we run DFS on a directed graph G, it is possible for a single vertex v ∈ G to be simultaneously incident on at least one back edge, forward edge, cross edge and tree edge.
  6. It is always cheaper to use a binary heap instead of a linked list to implemented Djikstra’s algorithm.
  7. Let X be a minimum spanning tree of the weighted undirected graph G(V,E). Let G’(V’, E’) be another graph defined by augmenting G with a new vertex u and some weighted edges incident on u. In other words, V’ = V ∪{u} and E’ = E ∪ F where F is a set of edges touching u. Then there is always a minimum spanning tree X’ of G’ such that X ⊂ X’.
  8. Let G(V,E) be an undirected graph. Then G has a cycle if and only if it is possible to put directions on all the edges in E so that every vertex in V has an edge pointing to it.
  9. The paths computed by Bellman-Ford after the 2nd^ iteration might be the shortest.
  10. Let T(0) = 1 and T(n) = 2 T(n-1)^ for n ≥ 1. Then the cost of computing T(n) and printing it out as a binary integer is θ(T(n-1)).
  11. If T(n) = 49 T(n/7) + n 2 cos√n, then T(n) = O(n 2 log n).
  12. Let G be an undirected graph, and let G’ be another undirected graph. G’ has one vertex for each biconnected component of G’ (and no other vertices). Two vertices in G’ are connected by an edge if and only if the two corresponding biconnected components in G share a vertex. Then G’ can have a cycle.

Problem 4 (18 Points)

Let T be a MST in the weighted graph G(V, E). Let G’(V’, E’) be a graph obtained by removing one vertex u from G (so that V’ = V – {u}), and by removing all the edges incident on u. Let e ∈ E any edge of T not incident on u. Prove that there is an MST of G’ that contains e. Hint: the cut property says:

Let X ⊆ T where T is a Minimum Spanning Tree (MST) in the weighted graph G(V, E). Let S ⊂ V such that no edge in X crosses between S and V – S; i.e. no edge in X has one endpoint in S and one endpoint in V – S. Among the edges crossing between S and V – S, let e be an edge of minimum weight. Then X ∪ {e} ⊆ T’ where T’is a MST in G(V, E).

Partial Answers to Problem 2

  1. True
  2. False
  3. False
  4. True
  5. True
  6. False 7.?
  7. False
  8. True
  9. True
  10. True
  11. True