



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Solutions to problem sets and exams for the algorithms and programs (cs 541) course at the university level. The problems involve implementing dynamic trees, understanding the admissible path algorithm, and modifying self-adjusting binary search trees. Students can use this document as a reference for studying and preparing exams, quizzes, or assignments related to these topics.
Typology: Exams
1 / 6
This page cannot be seen from the preview
Don't miss anything!
with several “virtual trees.” Show the corresponding set of “actual trees” (showing the vertex costs).
Assuming these trees are used to implement the admissible path algorithm, what is the residual capacity of the edge from j to d?
If the next step in the admissible path algorithm adds an edge from a to j and if this edge has a residual capacity of 5, what is the residual capacity of the next augmenting path?
label preflow-push algorithm. Show the state of the algorithm after each of the next two steps in which a vertex becomes balanced. You need not re-draw the entire residual graph, but do show all edges, vertices and associated values that are modified by each step.
s
d f
b e
t
5
(^3 )
2
3
6
1
1 2
c
2
3
2
8,
1,
9,
2,
(^70)
2,
5
3
6
1
residual capacity
distance label, excess
s
d f
b e
t
5
(^3 )
2
3
6
1
1 2
c
2
3
2
8,
1,
9,
2,
(^70)
2,
5
3
6
1
residual capacity
distance label, excess
s
d f
b e
t
5
(^3 )
2
3
6
3
(^1 )
c
2
3
2
8,
1, 1
9,
3 , 0
(^70)
2, 2
3
3
6
1
s
d f
b e
t
5
(^3 )
2
3
6
3
(^1 )
c
2
3
2
8,
1, 3
9,
3,
(^70)
2, 0
3
3
6
1
s
d f
b e
t
5
(^3 )
2
3
6
3
(^1 )
c
2
3
2
8,
1, 1
9,
3 , 0
(^70)
2, 2
3
3
6
1
s
d f
b e
t
5
(^3 )
2
3
6
3
(^1 )
c
2
3
2
8,
1, 3
9,
3,
(^70)
2, 0
3
3
6
1
cost. The vertices are ordered by the keys in the usual way (so the keys of the vertices in the left subtree of a given vertex x are strictly less than the key of x , and so forth). The costs are represented using the differential representation we used for representing path sets. Complete the recursive function search, shown below, so that it returns a least-cost vertex from among those vertices with keys smaller than a given bound. The structure of the tree nodes is shown below also. class twoWayTrees { int n; // trees defined on items {1,...,n} struct node { int k, Dc, Dm; // key and differential cost fields int lc, rc; // indices of left and right children } *vec;
... } #define left(x) (vec[x].lc) // you may assume similar declarations // for right, key, Dcost, Dmin int search(int t, int bound) { // Return the index of a least cost node from among those nodes // in the subtree with root t that have keys less than bound. // If there is more than one such node, pick the one with // the smallest key. Return Null, if there is no least cost node // with key less than bound. if (t == Null) return Null; else if (left(t) != Null && Dmin(left(t)) == 0) return search(left(t),bound); else if (key(t) < bound && Dcost(t) == 0) return t; else if (right(t) != Null && Dmin(right(t)) == 0) return search(right(t),bound); else return Null; }
find in the network shown below (the pairs on each edge are the capacity and the cost). Explain.
The algorithm finds 54 distinct augmenting paths in this graph. Initially, it finds 9 paths of the form s,a 1 ,x (^) i,y (^) j,d 1 ,t with capacity 1 and cost 0. At this point the edge from s to a 1 is saturated, as is the edge from d 1 to t. Next, it finds 9 paths of the form s,b 1 ,y (^) i,x (^) j,c 1 ,t with cost 2.Then, it finds 9 paths of the form s,2 2 ,a 1 ,x (^) i,y (^) j,d 1 ,d 2 ,t with cost 4. And so forth. It continues in this fashion, always just adding one unit of flow for each augmenting path, since all paths pass through the central bipartite subgraph.
Explain how this example can be generalized to show that the min-cost, augmenting path algorithm can take time Ω( n^5 ).
To generalize the example, make the a, b, c, and d chains all k vertices long, with edge costs of 0,2,4,... from s to each of the a vertices and from each of the d vertices to t. Make the edge costs from s to each of the b vertices and from each of the c vertices to t, equal to 1,3,5,... Make the capacities of all the edges incident to s and t k 2. Expand the central bipartite subgraph so that it has 2k vertices and edges from the x vertices to the y vertices with capacity 1 and cost 0. Assign infinite capacity and 0 cost to all other edges. In this graph, the min-cost augmenting path algorithm with find 2k 3 augmenting paths. Since it uses Dijkstra’s algorithm to find each augmenting path and since the graph has more
a 3 a 2 a 1
b 3 b 2 b 1
x 1 x 2 x 3
y 1 y 2 y 3
d 1 d 2 d 3
s t
∞,0 c 1 c 2 c 3
∞,
∞,
∞,
∞,
∞,
∞,
∞,
1,
∞,
∞,
9, 9,
9,4 9,
9,
9,
9,2 9,
9,1 9,
9,
9,
a 3 a 2 a 1
b 3 b 2 b 1
x 1 x 2 x 3
y 1 y 2 y 3
d 1 d 2 d 3
s t
∞,0 c 1 c 2 c 3
∞,
∞,
∞,
∞,
∞,
∞,
∞,
1,
∞,
∞,
9, 9,
9,4 9,
9,
9,
9,2 9,
9,1 9,
9,
9,