Docsity

Graph - Advanced Data Structures and Algorithms - Exam, Exams of Data Structures and Algorithms

Toggle sidebar
bg1
- 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.
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.
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.
CS 542 – Advanced Data Structures and Algorithms Jon Turner
Exam 1
Your name here: 2/14/2013 2/14/2013
pf3
pf4
pf5

Partial preview of the text

Download Graph - Advanced Data Structures and Algorithms - Exam and more Exams Data Structures and Algorithms in PDF only on Docsity!

  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. 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. 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.

CS 542 – Advanced Data Structures and Algorithms Jon Turner

Exam 1

Your name here: 2/14/ 2013 2/14/

  1. (1 0 points) If Dijkstra’s algorithm is applied to a graph with negative length edges, some vertices may get scanned more than once. Suppose we apply Dijkstra’s algorithm to the graph shown below, starting from vertex a. List the first 7 vertices that are scanned. In the diagram label each vertex with its tentative distance after the first 7 vertices are scanned and indicate the parent pointer of each vertex using an arrow pointing from each vertex to its parent. List the next two vertices to be scanned. List the next six. What is the total number of scanning steps that Dijkstra’s algorithm will perform on this graph? If you extended the graph by adding a fourth “diamond” to the left, with edge lengths of 8, 8, 32 and - 24, how many steps would be Dijkstra’s algorithm use for this graph? a b d c 4 4 (^17) - e g f 2 2 (^8) - h j i 1 1 (^3) -
  1. ( 15 points) The residual graph shown below is for some flow f on a flow graph G. What is the capacity of the edge connecting e and c in G (note: this is asking about G not R )? Justify your answer. Is the edge connecting c and e in G directed from c to e or from e to c? Justify your answer. (Hint: consider the total incoming flow at e. ) You may assume that there is no more than one edge joining any two vertices, but you should not assume anything about the direction of the edges at s and t (that is, G may have edges entering s or leaving t ). Find a shortest augmenting path relative to f and list the vertices on the path. Draw the residual graph that results from adding as much flow as possible to this path. s a c b d e t
  1. (10 points) Let Rf be a residual graph for a min-cost flow f , let p be a source-sink path in Rf with cost c and let q be a source-sink path in Rf with cost d. Let f + be the flow we get when we add enough flow to p to saturate it and let Rf + be the resulting flow graph. Does Rf contain a negative cycle? Explain your answer. If Rf + has no negative cycle, what does that tell us about p? Explain. If d < c does Rf + contain a negative cycle. Explain. If ( u , v ) is in Rf + but not in Rf , what does that tells us about ( u , v )? Explain. If ( u , v ) is in Rf but not in Rf +, what does that tell us about distf ( u ) and distf ( v ) (where distf ( x ) is the length of the shortest path from the source s to x in Rf )?
  1. ( 15 points) In the degree-constrained subgraph problem, we are given a graph G =( V , E ) and a degree bound b ( u ) for every vertex u. The objective is to find a subgraph of G in which every vertex u has at most b ( u ) incident edges. In the graph at right, find a degree-constrained subgraph with 6 edges. Indicate the edges in the subgraph by making them heavier weight. In the weighted version of the problem, each edge e has a weight w ( e ) and we are interested in the degree- constrained subgraph of maximum weight. Describe (in words) an algorithm to solve this problem when the graph is bipartite. Use the graph shown at right to illustrate your solution. Note that the shapes of the vertices define the division of the vertices into subsets. g a c b d e f 1 3 2 2 2 1 1 e c f

b g d a