Virtual Trees - Advanced Data Structures and Algorithms - Exam, Exams of Data Structures and Algorithms

Main points of this exam paper are: Implementation, Dynamic Trees Data Structure, Virtual Trees, Actual Trees, Vertex Costs, Admissible Path Algorithm, Algorithm Adds, Next Augmenting Path, Intermediate State, Associated Values

Typology: Exams

2012/2013

Uploaded on 03/23/2013

saruy
saruy 🇮🇳

4.5

(120)

130 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
- 1 -
1. (10 points) The figure below shows an implementation of the dynamic trees data structure
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?
CS 541 – Algorithms and Programs
Problem Set 2 Solutions
J
onathan Turne
r
Exam 2 - 10/28/03
CS 541 – Algorithms and Programs
Exam 3 Solutions
J
onathan Turne
r
12
/
4
/
03
aj
c
f
e
s
h
g
t
d
b0,2
0,2
0,3
0,98
0,1
0,1
0,2
0,5
0,99 0,3
0,100
aj
c
f
e
s
h
g
t
d
b0,2
0,2
0,3
0,98
0,1
0,1
0,2
0,5
0,99 0,3
0,100
pf3
pf4
pf5

Partial preview of the text

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

  1. (10 points) The figure below shows an implementation of the dynamic trees data structure 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?

CS 541 – Algorithms and Programs

Problem Set 2 Solutions

Jonathan Turner Exam 2 - 10/28/

CS 541 – Algorithms and Programs

Exam 3 Solutions

Jonathan Turner 12/4/

a j

c

f

e

s

h

t g

b 0,2 d

a j

c

f

e

s

h

t g

b 0,2 d

  1. (10 points) The figure below shows the an intermediate state in the execution of the highest 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

s c t

d f

b e

c t

s

d f

b e

s c t

d f

b e

c t

  1. (20 points) Consider a binary search tree in which each vertex has an associated key and a 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.

5. (15 points) How many augmenting paths does the min-cost, augmenting path algorithm

find in the network shown below (the pairs on each edge are the capacity and the cost). Explain. Explain how this example can be generalized to show that the min-cost, augmenting path

  • a 3 a 2 a algorithm can take time Ω( n^5 ).
  • b 3 b 2 b - x 1 x 2 x - y 1 y 2 y - d 1 d 2 d - ∞,0 c 1 c 2 c s t - ∞, - ∞, - ∞, - ∞, - ∞, - ∞, - ∞, - 1, - ∞, - ∞, - 9,3 9,
    • 9,4 9,
    • 9, - 9, - 9,2 9, - 9,1 9, - 9, - 9,
  • a 3 a 2 a
  • b 3 b 2 b - x 1 x 2 x - y 1 y 2 y - d 1 d 2 d - ∞,0 c 1 c 2 c s t - ∞, - ∞, - ∞, - ∞, - ∞, - ∞, - ∞, - 1, - ∞, - ∞, - 9,3 9,
    • 9,4 9,
    • 9, - 9, - 9,2 9, - 9,1 9, - 9, - 9,