Sunteți pe pagina 1din 2

R

IS

UN

Dr. Surender Baswana

FR 6.2 Informatik

E R SIT

I N F O R M A T I K

SA

Universitat
des
Saarlandes

IV

A VIE N

WS 2004/5

Exercises for Randomized Algorithms


4. Assignment

Due : Due on 25th December.

Be very rigorous in your arguments. Specify any probability Lemma/Theorem explicitly before you use it.
Exercise 1 (1,1,8)
Decremental connectivity in a Tree Given a tree T on n vertices. We receive a sequence of queries
interspersed with edge-deletions. Each query asks whether any two given vertices are connected or not. We
need to answer each query online incorporating all edge deletions prior to the query. Here is a simple algorithm
that would answer any such query in just constant time. The algorithm maintains the following invariant :

I : at every stage, all vertices of a tree are assigned a unique label which is index of some vertex (called root)
in the tree.
This invariant implies that any two vertices are connected at an instance if they have same label at that instance.
So each query takes O (1) time. We describe the algorithm as follows :
Let L[n be an array storing label for every vertex. To begin with, we pick a vertex, say v , from T as the root.
We perform a traversal rooted at v and label every vertex with v . (So L[u = v; 8u 2 V ). We can answer any
connectivity query in O (1) time until an edge is deleted from T . Let x y be the first edge that is deleted.
The tree T gets split into two subtrees : the subtree Tx containing x and the another subtree Ty containing y . If
v 2 Tx , then the invariant I holds for the vertices of Tx but not for Ty . So we need to update the labeling of all
the vertices of Ty . We pick a root vertex w from Ty and traverse Ty changing the label of all the vertices of Ty
to w now. The algorithm continues in this manner while maintaining the invariant I at every stage ...
The work done by the algorithm in maintaining array L[ (traversing the trees, changing the labels) is the total
update time of the algorithm.
a) When an edge x y is deleted, how can we determine whether the root of original tree T belongs to Tx
or not in just O (1) time ?
Hint : Instead of performing any arbitrary traversal, perform BFS traversal and store, in addition to the
label, the ... information for every vertex in the tree.
b) Show that the worst case update time of the above algorithm is  (n2 ).
c) Now consider just a slight modification of the algorithm : while labeling the vertices of a tree, we select
the root vertex randomly uniformly.
Show that the expected update cost for this randomized algorithm will be O (n log n).
Note : It is crucial in the above algorithm that randomness is not in the sequence of edge-deletions.

Exercise 2 (4,3,3)
Consider a problem P defined as :
Suppose there are i random variables x1 ;    ; xi with some probability distribution (the distribution is known to
us). If we are given some partial information about these random variables e.g. none of them is larger/smaller
than some , what can we say about the probability distribution of the random variables (conditioned on this
information)?
We encountered the problem P while solving the problem : what is the expected weight of MST in a complete graph with each edge weight uniformly independently distributed in [0; 1 ? We considered step by step
execution of the Kruskals algorithm for MST and tried to bound the expected weight of ei (ith edge of MST in
Kruskals algorithm). Actually, we tried to bound expected value of 4i = wt(ei ) wt(ei 1 ). But in doing so
we realized that the weight of ei is dependent on the weight of the i 1 edges already picked for the MST. So we
wanted to compute E[4i je1 ; e2 ;    ; ei 1 , that is the expected difference in the weight of ith and (i 1)th edge
of the MST given the set of first i 1 edges of MST during the Kruskals algorithm. To compute this quantity,
we required the knowledge of the distribution of the weight of the remaining edges of the graph conditioned on
the weight of first i 1 edges of the MST picked so far. The problem P was used at this point.
We now use P to solve one more problem. :
Let Gn be a complete graph on n vertices with weight of each edge chosen independently uniformly from the
range [0,1]. Let d(u; v ) denote the shortest distance between u and v . Out objective is to compute the expected
value of maxv d(u; v ), that is the expected distance from u to its farthest vertex in the graph.
To solve this problem, we proceed in a way similar to that of bounding the expected weight of MST in a
complete graph. Consider the Dijkstras algorithm executed from u step by step to grow the shortest path tree
rooted at u. Initially, to begin with, the shortest path tree is T0 = fug. The ith step begins with tree Ti 1 ,
to which we add the next vertex nearest to u, say vi from the set V nTi 1 in order to get Ti . Let di denote
the distance from u to the vertex vi in Ti . Clearly di is a random variable and its value is dependent on the
d1 ; d2 ;    ; di 1 . Let i = di di 1 .
a) We shall try to compute expected value of i conditioned on a given Ti 1 . Let Ek ; k < i be the set of
edges emanating from vk 2 Ti 1 onto the vertices outside Ti 1 . Note that these edges are going to decide
the value of i (and hence di ). Now conditioned on a fixed Ti 1 , that is, conditioned on dj = j ; j < i,
where j s are some fixed constants, what is the distribution of the weights of the edges from set Ek .
(Give precise answer in terms of constants j s)
b) Use (a) to get a bound on E[i jd1
c)

   ; d 1 = 1.
Remove conditioning in (b) to get a good estimate on E[ . Finally give a bound on E[max
= 1 ; d2 = 2 ;

d(u; v ).

S-ar putea să vă placă și