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

Partition Data Structure - Advanced Data Structures and Algorithms - Solved Exam, Exams of Data Structures and Algorithms

Main points of this past exam are: Advanced Data Structures, Algorithms, Partition Data Structure, Smallest Number, Nodes, Partition Data Structure, Root, Million Nodes, Dominant Node, Dominant Immediately

Typology: Exams

2012/2013

Uploaded on 03/23/2013

sardai
sardai 🇮🇳

4

(10)

117 documents

1 / 7

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
- 1 -
1. (15 points) Consider a find operation on the partition data structure in which the “find
path” has 21 nodes. What is the smallest number of nodes that the partition data structure
could contain. Explain your answer.
Since ranks must increase as you go up the find path, the rank of the root must be at least 20. Since
the rank is at most lg n, we must have at least 220 nodes.
In the O(m log log n) analysis of the partition data structure, we defined the notion of a
dominant node. Suppose the partition data structure has 16 million nodes. If the root of the
tree involved in the above find operation has a rank of 30, what is the maximum number of
nodes along the find path that could be dominant? Explain your answer.
The
Δ
values for the dominant nodes must increase by more than a factor of >2 as you go up the find
path, so to maximize the number of dominant nodes, we could have the sequence of
Δ
values: 1, 3, 7,
15. The next
Δ
value in the sequence is 31 which is too large, given that the rank of the root is just 30.
So, there can be at most 4 dominant nodes. In fact, since the other nodes have a
Δ
of at least 1, even
four dominant nodes is too many to keep the rank of the root from exceeding 30. With 3 dominant
nodes, we can have 17 non-dominant nodes with a
Δ
of 1. Adding this to 1+3+7 gives 28, which is
smaller than the given root rank of 30. So the maximum number of dominant nodes is 3.
Consider a node x with rank(x)=0 and rank(p(x))=8. Suppose we perform three operations
involving node x and x is not dominant immediately before each of these find operations.
What is the smallest possible value that rank(p(x)) can have after these three find operations
have completed? Explain your answer.
Each of the finds must increase the rank(x) by at least a factor of 3/2. So, the three finds increase it
from 8 to at least 8(3/2)3=27.
CS 542 – Advanced Data Structures and Algorithms
Exam 2 Solutions
Jonathan Turner 4/2/2012
pf3
pf4
pf5

Partial preview of the text

Download Partition Data Structure - Advanced Data Structures and Algorithms - Solved Exam and more Exams Data Structures and Algorithms in PDF only on Docsity!

  1. (15 points) Consider a find operation on the partition data structure in which the “find path” has 21 nodes. What is the smallest number of nodes that the partition data structure could contain. Explain your answer. Since ranks must increase as you go up the find path, the rank of the root must be at least 20. Since the rank is at most lg n, we must have at least 2^20 nodes. In the O ( m log log n ) analysis of the partition data structure, we defined the notion of a dominant node. Suppose the partition data structure has 16 million nodes. If the root of the tree involved in the above find operation has a rank of 30, what is the maximum number of nodes along the find path that could be dominant? Explain your answer. The Δ values for the dominant nodes must increase by more than a factor of >2 as you go up the find path, so to maximize the number of dominant nodes, we could have the sequence of Δ values: 1, 3, 7, 15. The next Δ value in the sequence is 31 which is too large, given that the rank of the root is just 30. So, there can be at most 4 dominant nodes. In fact, since the other nodes have a Δ of at least 1, even four dominant nodes is too many to keep the rank of the root from exceeding 30. With 3 dominant nodes, we can have 17 non-dominant nodes with a Δ of 1. Adding this to 1+3+7 gives 28, which is smaller than the given root rank of 30. So the maximum number of dominant nodes is 3. Consider a node x with rank ( x )=0 and rank ( p ( x ))=8. Suppose we perform three operations involving node x and x is not dominant immediately before each of these find operations. What is the smallest possible value that rank ( p ( x )) can have after these three find operations have completed? Explain your answer. Each of the finds must increase the rank(x) by at least a factor of 3/2. So, the three finds increase it from 8 to at least 8(3/2)^3 =27.

CS 542 – Advanced Data Structures and Algorithms

Exam 2 Solutions Jonathan Turner 4/2/

  1. ( 12 points) The diagram below shows a partial representation of an intermediate state in the execution of the nearest-common ancestor algorithm. In the depth-first-search, which nodes are open? a, c and g are open, What is the nearest open ancestor for each of the nodes s , n and f? noa(s)=c, noa(n)=g, noa(f)=a For which pairs has the algorithm computed the nca values at this point? {j,t}, {d,r} Show how the partition changes after the current recursive call to the nca function returns Partition e a f b d c h g j i r q k^ m p^ n s j i s d r q p^ n t h t a b c f k e m g pairs : { i , g ), { j , t }, { e , r }, { d , r }, { e , k } tree

j

i

s d

r

q

p n h

t

a b

c

f k e m

g

  1. (15 points) The figure below shows an intermediate stage in the execution of Edmonds algorithm for finding a maximum size matching. The matching edges are not shown explicitly, but parent pointers are shown and the partition data structure is shown. Draw closed curves around the vertex sets which form blossoms in the current graph. Mark the bridges of the blossoms with a B. Mark even vertices with a plus sign and odd vertices with a minus sign. Indicate which edges are in the current matching, by marking them with an M. If edge { g , h } is processed next, an augmenting path is found. List the vertices in that augmenting path. sknmghbecr

b

s g h

k

d e

a

n m q

j

c

i

p

r

+^ -

B

B

  1. ( 20 points) In the analysis of the shortest augmenting path algorithm, we defined leveli ( u ) to be the length of the shortest path from s to u in the residual graph, after the i - th augmenting step. As the algorithm progresses, leveli ( t ) increases at various points and we can define a phase to be the period between two successive changes to leveli ( t ). What is the largest number of phases that the shortest augmenting path algorithm will execute on a unit network with n vertices and m edges? Explain your answer. 2(n-2)1/2^ based on the analysis for Dinic’s algorithm, since the phases defined here correspond directly to the phases used in Dinic’s algorithm. Suppose that for a given phase leveli ( t ) = k. Give an upper bound on the number of augmenting path steps in that phase. (Hint: in a unit network, can two augmenting paths found in the same phase pass through the same vertex?) Explain your answer. Each node can only be used once in a phase, since each edge has just one incoming or outgoing edge and the edge capacities are all 1. Consequently, the number of augmenting paths in the phase is at most (n-2)/k Now, give an upper bound on the time spent finding augmenting paths of length k. Since each augmenting path search takes O(m) time, the total time spent is O(mn/k) Now, use the results from the last two steps to derive an upper bound on the total time spent by the shortest augmenting path algorithm on a unit network. If N is the max number of phases, the running time is O(mn(1+1/2+1/3+...+1/N))=O(mn log N) =O(mn log n).
  1. (20 points) In the analysis of the self-adjusting binary search trees, a certain number of credits are allocated to each splay. Suppose that 25 credits are allocated to a splay at node x. What is the smallest possible number of nodes in the tree? Explain your answer. If r is the root of the tree then the number of allocated credits is 3(rank(r) - rank(x) + 1. Since this number is 25, the difference in rank between x and r is 8. This implies that rank(r) is at least 8. In this context, the rank of a node is the floor of the lg of the number of descendants that it has. Hence the number of nodes is at least 256. What is the change to the value of rank ( x ) as a result of this splay? Explain your answer. After the splay, x is the root of the tree, so it has the same rank that r had originally. So, the rank(x) increases by 8. Suppose that a splay at a node x has ten splay steps, all of which involve a double-rotation. Suppose that for six of these splay steps, p ( p ( x )) has the same rank as x and for the remaining steps the rank of p ( p ( x )) is equal to rank ( x )+3. If C 1 is the number of credits needed to maintain the credit invariant before the splay, and C 2 is the number needed after the splay, give a lower bound on the difference C 1 C 2. Explain your answer. From the analysis of the self-adjusting search trees, we know that when we do a double rotation with rank(x)=rank(p(p(x))), at least one credit is released (that is, we need at least one fewer credit after the step than we did before the step). So, the 6 steps for which rank(x)=rank(p(p(x))), release at least 6 credits. We also know that when rank(x)<rank(p(p(x))), that at least 1/3 of the credits allocated to the step are released. Each of the four steps with rank(p(p(x)))=rank(x)+3 has 9 credits allocated to it. Since 3 of these are no longer needed after the step, we gain a total of 12 credits from these steps. Combining these results, we have that C 1 C 2 is at least 18.