Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Shortest Path Version - Advanced Data Structures and Algorithms - Solved Exam, Exams of Data Structures and Algorithms

Main points of this past exam are: Shortest Path Version, Advanced Data Structures, Augmenting Path Algorithm, Residual Graph, Paths Sadt, Augmenting Path Algorithm, Shortest Augmenting, Augmenting Path, Intermediate State, Edmonds Algorithm

Typology: Exams

2012/2013

Uploaded on 03/23/2013

sardai
sardai 🇮🇳

4

(10)

117 documents

1 / 9

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
- 1 -
1. (10 points) In the analysis of the shortest path version of the augmenting path algorithm Ri
was defined to be the residual graph for the flow on the graph following the i-th
augmenting path step. In the flow graph below, assume that the first two steps of the
augmenting path algorithm select the paths sadt and scet.
Draw R2 and label each vertex u with the value of level2(u).
The shortest augmenting path algorithm selects the edges in the augmenting path from a
subset of the edges in Ri. In the example flow graph, which edges are in this set of eligible
edges for R2?
Edges sa, sc, ad, ab, cb, be, de, et are all eligible
CS 542 – Advanced Data Structures and Algorithms
Final Exam Solutions
Jonathan Turner 5/7/2012
s
a
c
b
d
e
t
2
3
2
3
4
5
6
7
6 2 1
5
s
a
c
b
d
e
t
2
3
2
3
2
2
6
4
3 2 1
5
2
3
3
3
1
0
1
3
2
2
4
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Shortest Path Version - Advanced Data Structures and Algorithms - Solved Exam and more Exams Data Structures and Algorithms in PDF only on Docsity!

  1. ( 10 points) In the analysis of the shortest path version of the augmenting path algorithm R i

was defined to be the residual graph for the flow on the graph following the i - th

augmenting path step. In the flow graph below, assume that the first two steps of the

augmenting path algorithm select the paths sadt and scet.

Draw R 2

and label each vertex u with the value of level 2

( u ).

The shortest augmenting path algorithm selects the edges in the augmenting path from a

subset of the edges in R i

. In the example flow graph, which edges are in this set of eligible

edges for R 2

Edges sa, sc, ad, ab, cb, be, de, et are all eligible

CS 542 – Advanced Data Structures and Algorithms

Final Exam Solutions

Jonathan Turner 5/7/201 2

s

a

c

b

d

e

t

s

a

c

b

d

e

t

  1. (1 0 points) The diagram below shows a partial representation of an intermediate state in the

execution of Edmonds algorithm for maximum size matching.

Identify three blossoms in the graph by drawing closed curves around them. Recall that one

blossom may be contained in another.

Write down the vertex sets defined by the partition data structure at this point in the

execution of the algorithm.

{a}, {b}, {c,d,e,h,i,j,k,o,p,x,w}, {g,m,s,n,t}, {u}, {v}

Mark the bridges of the blossoms with a B.

If edge { i,n } is processed next, an augmenting path is found. List the vertices in that

augmenting path.

a,b,h,c,d,j,e,k,x,w,p,o,i,n,t,s,m,g

a

c

b

d

e

g

i

h

j

k

m

o

n

p

x

s

u

t

v

w

B

B

B

  1. (10 points) The diagram below shows an intermediate state in the execution of Dinic’s

algorithm with dynamic trees. The nextedge pointers are indicated by the dots on the edges.

Assume that these start at the “12-oclock” position and rotate clockwise.

Notice that costs have been omitted for vertices b and k. What values should they have?

cost(b)=2 and cost (k)=

Assume that in the state shown above, the findpath method is called. What edges are

removed from the dynamic trees data structure during the execution of findpath.

ac and bc are removed

For each of the edges that are removed what flow values are assigned to those edges in the

flow graphs?

ac is assigned a flow of 2, bc is assigned a flow of 4

What edges are added during the execution of findpath?

bd, df, fh and hj

For each vertex in the dynamic trees data structure for which the cost changes during the

execution of findpath , what is the new cost value?

cost(b)=4, cost(d)=2, cost(f)=3, cost(h)=

g

t

h

i

k

j

a e

b

c

d f

s

_

H

_ H

H

capacity, flow

cost

  1. ( 12 points) The tree shown below is what Tarjan refers to as a virtual tree in the dynamic

trees data structure (that is, it represents the underlying implementation of the abstraction

provided by the data structure). The dynamic trees data structure represents information

about paths with positive residual capacity in a flow graph. In the tree below, assume that s

is the source vertex and t is the sink of the flow graph.

Identify an augmenting path from s to t ; list the vertices in the order they occur in the flow

graph. Hint: think about the “actual tree” represented by this virtual tree.

skfnbadchgt

What is the residual capacity of the augmenting path?

Suppose you did an expose operation at the source node, s. After the expose, which vertices

would be in the same binary search tree as vertex m?

x,z,w,m

2,

! min ,! cost

b d

e c

a

0,

1,

0,0 0,0 9,

n

t

m

3,

2,

88,

i

s f

h

k

2,

3,

3,

1, 0,

p g

5,

x w

z

3,

2, 0,

  1. (15 points) In the analysis of the FIFO variant of the preflow-push method for max flows, a

potential function is used to account for the number of steps in which flow is added to an

edge, but the edge is not saturated. The potential function is defined to be the maximum of

the distance labels of the unbalanced vertices (that is, the vertices that have positive excess

flow). Suppose we have a graph with 100 vertices and 1000 edges. Give a numerical upper

bound on the value of the potential function.

P(u)<2n=200 for all u

In the analysis, we defined a phase to end when all the vertices on the queue at the start of

the phase have been processed. Explain why every phase that contains no relabeling

operation, causes the potential function to decrease.

Let X be the set of vertices that are on the queue at the start of the phase. Each vertex in X becomes

balanced during the phase (since all vertices that we cannot balance get relabeled). Hence, the only

vertices that are unbalanced at the end of the phase, are vertices which became unbalanced because we

pushed flow into them. Call this set of vertices Y. Every vertex u in Y has a smaller label than some

vertex in X (from which flow was pushed to u). Hence, the largest label for the vertices in Y must be

smaller than the largest label for the vertices in X. Hence, the potential function must decrease during

the phase.

Consider a step that adds flow to an edge ( u , v ) and saturates it. Can such a step cause the

potential function to increase? Why or why not?

No, because even if v becomes unbalanced, it’s label is smaller than that of u.

Consider a step that relabels a vertex. Can such a step cause the potential function to

decrease? Why or why not?

No, because a relabeling step can only increase the label of the vertex being relabeld, and does not

make any new vertex unbalanced.

Give an upper bound on the sum of the increases in the potential that could result from all

steps that relabel a vertex.

The total increase is <2n since the potential never decreases and cannot exceed 2n

  1. (12 points) The graph at left below has negative length edges. In the diagram at right, give

transformed edge lengths that preserve the relative lengths of shortest paths.

Let G be an arbitrary graph with negative length edges and let length ’( u , v ) be the

transformed edge length for ( u , v ). Suppose p is a path from x to y with length ( p )= 3 and

length ’( p )=7. If q is another path from x to y with length ( q )=3, what is length ’( q )?

length’(q) = length(q) + (length’(p) - length(p)) = 3 + (7 - (-3)) = 13

In the min-cost augmenting path algorithm (for the min-cost flow problem) using

transformed edge costs, a new shortest path tree is computed during each step, and the

shortest path distances are used to modify the edge costs. What is the total cost of the edges

in the shortest path tree, using the newly modified costs? Explain.

The total cost is 0. For each edge (u,v), the new cost’(u,v) = cost(u,v) + dist(u) - dist(v). If (u,v) is an

edge in the shortest path tree, then dist(v) = dist(u) + cost(u,v), and hence cost’(u,v)=0. Since this is

true for all edges in the shortest path tree, the total cost is 0.

e

b d

f

a c

e

b d

f

a c