You are on page 1of 2

Dr.

Surender Baswana

IS

UN

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


1. Assignment

Due : 11 November

Be very rigorous in your arguments. Specify any probability Lemma/Theorem explicitly before you use it.
Exercise 1 (8)
Given n balls and n bins. We throw each ball randomly into the bins (each bin is equally likely to be the
destination of a ball).
a) What is the expected number of bins containing one ball ?
b) How small a number k can you find such that the probability that a particular bin has exactly k balls is
less than 1=n3 ?
c) Use b) and Booles inequality to show that the probability that there is any bin with more than log n
balls (for sufficiently large ) is at-most 1=n.
Exercise 2 (6)
A bin contains m white balls and n black balls. We take out the balls uniformly randomly from the bin without
replacing them. What is the expected number of black balls left when all the white balls have been taken out ?
Exercise 3 (10)
Let S be a set of n real numbers. Consider the following randomized algorothm Rand-Select(k; S ) that finds
(selects) k th largest element from the set S .
Select a random element p from set S . Find its rank in the set S (by comparing p with every other element of
set S ). Let r be the rank of p. If r = k , we report p as the output. Otherwise we proceed recursively as follows :
If r > k , then Rand-Select(k; S<p )
Else Rand-Select(k r; S>p )
where S<p and S>p are the sets consisting of all those elements that are respectively smaller and greater and
than the element p. The running time of the above algorithm is dominated by the number of comparisons
performed. Our aim is to find the expected number of comparisons made in Rand-Select(k; S ).
Let Xj be a random variable which is the number of comparisons performed between element ej (the j th largest
element of set S ) and elements smaller than ej during the algorithm.




What is the expected value of Xj for j < k ?


What is the expected value of Xj for j > k ?
(Hint : Express Xj as a sum Yij ; i < j , where Yij is a random variable which is 1 if ei is compared with
ej during execution of the algorithm, and zero otherwise. Compute Pr(Yij = 1) carefully).

Show that the expected running time of the Rand-Select algorithm is O (n).

Show that max8in E[Xi is  (log n) ? This shows that eventhough, on an average, an element is compared constant number of times during the algorithm, there are some elements which are compared  (log n)
during the algorithm. Can you say anything about the vicinity of these elements with respect to the k th
largest element ?

Exercise 4 (6)
The Aethernet corporation has developed an exciting new protocol to let a collection of m machines communicate on a shared wire. Time is divided into fixed slots. In a slot, any machine that wants to send information
to another can broadcast it onto the wire. If exactly one request is broadcast in the slot, that broadcast is successfully completed. If more than one broadcast is attempted, none are successful.
a) Assuming that the number of machines n that wish to broadcast is known, devise a randomized protocol
that will, with no communication overhead, let some broadcast succeed with constant probability in each
time slot, without favoring any particular machine.
b) Assume that there is a fixed set of n machines, each of which repeatedly tries (in every slot) to send (an
infinite sequence of) packets using the protocol from the previous part. What is the expected time until
every machine has sent its first packet?

You might also like