



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
Main points of this past exam are: Advanced Data Structures, Dynamic Trees Data Structure, Virtual Tree, Tarjan Calls, Individual Weight, Dynamic Trees, Analysis, Total Weight Function, Correctness, Balanced Binary
Typology: Exams
1 / 7
This page cannot be seen from the preview
Don't miss anything!




In the analysis of dynamic trees, we defined an individual weight function on the vertices and a total weight function. What is the individual weight of c? What is the total weight of e?
iw(c)=6, tw(e)=
0,3 g
k
d
i f
e
j
h (^) b
a
c
∆cost, ∆min
0,3 g
k
d
i f
e
j
h (^) b
a
c
∆cost, ∆min
For 1 ≤ u ≤ n,if vec[u].lchild ≠ Null then 1 ≤ vec[u].lchild ≤ n. For 1 ≤ u ≤ n,if vec[u].rchild ≠ Null then 1 ≤ vec[u].rchild ≤ n. For 1 ≤ u ≤ n,if vec[u].parent ≠ Null then 1 ≤ vec[u].parent ≤ n. For 1 ≤ u ≤ n,vec[u].rank >.
For 1 ≤ u ≤ n, if vec[u].lchild=v ≠ Null then vec[v].parent=u. For 1 ≤ u ≤ n, vec[u].rchild=v ≠ Null implies that vec[v].parent=u.
The pointers must define a collection of trees. Specifically, this means that for 1 ≤ u ≤ n,vec[u].lchild ≠ vec[u].rchild and the parent pointers do not define any cycles.
For 1 ≤ u ≤ n, if vec[u].lchild=v ≠ Null then vec[v].keyfield<vec[u].keyfield. For 1 ≤ u ≤ n, if vec[u].rchild=v ≠ Null then vec[v].keyfield>vec[u].keyfield.
For 1 ≤ u ≤ n, if vec[u].parent=v ≠ Null then vec[u].rank ≤ vec[v].rank ≤ vec[u].rank +1_. If vec[v].parent=w_ ≠ Null then vec[u].rank<vec[w].rank. For 1 ≤ u ≤ n, if vec[u].lchild=Null or vec[u].rchild=Null, then vec[u].rank=1.
How does your answer change if t is an ancestor of s , initially? Explain.
In this case, the depth of t can increase by 3 during the splay step that makes t a descendant of s, but then it will decrease. Consequently,
Do you think that it would be worthwhile modifying the implementation of self-adjusting binary search trees to allow the use of these larger splay steps? Why or why not?
It might be, but one would need to try it out and compare the two in order to be sure. The larger splay steps do seem to do a better job of balancing the tree, since they move vertices that are far from the root, closer to the root, than do the “standard” splay steps. On the other hand, there is some extra overhead associated with determining which of the different splay steps is applicable in a given situation. This could completely offset the speedup obtained by improving the balance.
∆cost'(z) = ∆cost(z) + ∆min(z)
∆cost'(z) = cost'(z) − mincost'(z) = cost(z) − mincost(x) = cost(z) − (mincost(z) − ∆min(z)) = ∆cost(z) + ∆min(z)
∆min'(c) = ∆min(c) + ∆min(z)
∆min'(c) = mincost'(c) − mincost'(z) = mincost(c) − mincost(x) = (mincost(c) − mincost(z)) + (mincost(z) − mincost(x)) = ∆min(c) + ∆min(z)
∆cost'(z) = ∆cost(z) + ∆min(z)
∆cost'(z) = cost'(z) − mincost'(z) = cost(z) − mincost(x) = cost(z) − (mincost(z) − ∆min(z)) = ∆cost(z) + ∆min(z)
∆min'(c) = ∆min(c) + ∆min(z)
∆min'(c) = mincost'(c) − mincost'(z) = mincost(c) − mincost(x) = (mincost(c) − mincost(z)) + (mincost(z) − mincost(x)) = ∆min(c) + ∆min(z)
Draw the residual graph corresponding to this flow, and for each vertex, determine its distance from s using the transformed costs. Write the distances by the vertices and mark the edges that are in the shortest path tree from s. Identify a minimum cost augmenting path in the graph. What is its cost, using the transformed costs?
The path s, c, b, e, t is a minimum cost augmenting path with cost 1.
What is the new value of the vertex label for e when this step is finished? For t?
The new distance label for e is 2. The new distance label for t is 1.
s
b
a
8,2,
3,3,
4,3,
6,−2,
8,6,
3,2,0 5,1,
5,1,0 3,1,
e
d
t
5,−1,
6,3,
7,5,
capacity, cost, flow
− (^1) label
0 − 2
2
1
0
− 1
s c
b
a
8,2,
3,3,
4,3,
6,−2,
8,6,
3,2,0 5,1,
5,1,0 3,1,
e
d
t
5,−1,
6,3,
7,5,
capacity, cost, flow
− (^1) label
0 − 2
2
1
0
− 1
c
s
b
a
8,
3,− 3
4,
3,− 2
8,
3,2 5,
5,1 3,
e
d
t
2,− 1
6,
7,
0
1
0
0
1
0
0
c 3,
3,
s
b
a
8,
3,− 3
4,
3,− 2
8,
3,2 5,
5,1 3,
e
d
t
2,− 1
6,
7,
0
1
0
0
1
0
0
c 3,
3,