



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
Main points of this exam paper are: Advanced Data Structures, Dynamic Trees Data Structure, Alphabetically, Individual Weight Function, Total Weight Function, Data Structure Operation, Essential Properties, Balanced Binary, Implementation, Self-Adjusting Binary
Typology: Exams
1 / 7
This page cannot be seen from the preview
Don't miss anything!
Show the underlying representation of this tree (what Tarjan calls the virtual tree). Be sure
to show the cost of each vertex using the differential form. Arrange each of the binary search
trees so that the label of the node at the root of the BST comes first alphabetically, among all
nodes in the BST.
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?
CS 541 โ Algorithms and Programs
CS 542 โ Advanced Data Structures and Algorithms
certain essential properties of the data structure. The data portion of the class declaration
for the C++ implementation of the balanced binary search tree data structure is shown
below. What properties of the data must be maintained by programs that operate on it? List
as many properties as you can.
class bbsts {
int n; // trees defined on nodes {1,...,n}
struct node { // tree node structure
int lchild, rchild, parent;
int rank;
keytyp keyfield;
} *vec;
...
};
How does your answer change if t is an ancestor of s , initially? Explain.
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?
that โ min and โ cost be updated during a rotation operation. Show that the two equations
below are correct.
โ cost'(z) =
โ cost(z)
โ min'(c) =
โ min(c) +
โ min(z)
cost,
min
z
x
b c
a
x
z
a b
c
cost
min
โ cost'(z) =
โ cost(z)
โ min'(c) =
โ min(c) +
โ min(z)
cost,
min
z
x
b c
a
x
z
a b
c
cost
min
cost,
min
z
x
b c
a
x
z
a b
c
cost
min
cost,
min
z
x
b c
a
cost,
min
z
x
b c
a
z
x
b c
aa
x
z
a b
c
cost
min
x
z
a b
c
x
z
a b
c
cost
min
โ cost'(z) =
โ cost(z)
โ min'(c) =
โ min(c) +
โ min(z)
cost,
min
z
x
b c
a
x
z
a b
c
cost
min
โ cost'(z) =
โ cost(z)
โ min'(c) =
โ min(c) +
โ min(z)
cost,
min
z
x
b c
a
x
z
a b
c
cost
min
cost,
min
z
x
b c
a
x
z
a b
c
cost
min
cost,
min
z
x
b c
a
cost,
min
z
x
b c
a
c
a
x
z
a b
c
cost
min
cost,
min
z
x
b c
a
x
z
a b
c
cost
min
cost,
min
z
x
b c
a
cost,
min
z
x
b c
a
z
x
b c
aa
x
z
a b
c
cost
min
x
z
a b
c
x
z
a b
c
cost
min
cost augmenting path algorithm for the min-cost max-flow algorithm, using vertex labels to
represent transformed costs.
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?
What is the new value of the vertex label for e when this step is finished? For t?
s
b
a
e
d
t
capacity, cost, flow
label
s c
b
a
e
d
t
capacity, cost, flow
label
c