0% found this document useful (0 votes)
17 views

Tutorial 2, Design and Analysis of Algorithms, 2024

Tutorial 2, Design and Analysis of Algorithms, 2024

Uploaded by

abhishek.mishra
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Tutorial 2, Design and Analysis of Algorithms, 2024

Tutorial 2, Design and Analysis of Algorithms, 2024

Uploaded by

abhishek.mishra
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Tutorial 2, Design and Analysis of Algorithms, 2024

1. A fair coin is flipped n times. Let Xi j , with 1 ≤ i < j ≤ n, be 1 if the ith and jth flip landed on
the same side; let Xi j = 0 otherwise. Prove that Xi j are pairwise independent, but not 3−wise
independent.
Random variables X1 , X2 , ..., Xn are pairwise independent if ∀i ̸= j and ∀a, b
Pr((Xi = a) ∧ (X j = b)) = Pr(Xi = a)Pr(X j = b)
Random variables X1 , X2 , ..., Xn are 3−wise independent if ∀i ̸= j ̸= k and ∀a, b, c
Pr((Xi = a) ∧ (X j = b) ∧ (Xk = c)) = Pr(Xi = a)Pr(X j = b)Pr(Xk = c)

2. Consider the following algorithm A():


0 A()
1 j←3
2 do
3 j ← j+1
4 n ← RANDOM(0, j − 1)
5 while n > 1
6 output j
Here RANDOM(m, n) returns a random integer between m and n (both inclusive) with uni-
form probability.
(a) Find the probability of halting of A().
(b) Find the expected number of iterations of the while loop in A().
3. An array A[1..n] contains n distinct numbers that are randomly ordered, with each permu-
tation of the n numbers being equally likely. What is the expectation of the index of the
maximum element in the array? What is the expectation of the index of the minimum ele-
ment in the array?
4. A permutation on the numbers [1..n] can be represented as a function π : [1..n] → [1..n],
where π(i) is the position of i in the ordering given by the permutation. A fixed point of a
permutation π : [1..n] → [1..n] is a value for which π(x) = x. Find the expected number of
fixed points of a permutation chosen uniformly at random from all permutations.
5. A parallel computer consists of n processors and n memory modules. During a step, each
processor sends a memory request to one of the memory modules. A memory module can
satisfy one request in a step; modules that receive more than one requests will satisfy one
request and discard the rest. Assuming that each processor chooses a memory module in-
dependently and uniformly at random, what is the expected number of processors whose
requests are satisfied?
6. Let Y be a non-negative integer-valued random variable with positive expectation. Prove the
following inequalities

1
E[Y 2 ] − E[Y ]2
(a) Pr[Y = 0] ≤ .
E[Y ]2
E[Y ]2
(b) ≤ Pr[Y ̸= 0] ≤ E[Y ]. Use Jensen’s inequality E[Y |Y ̸= 0]2 ≤ E[Y 2 |Y ̸= 0].
E[Y 2 ]
7. Suppose you are provided with a source of unbiased random bits. How will you generate a
2 3
sample from the set 0, 1 with probability distribution Pr[0] = and Pr[1] = .
5 5
8. Let X and Y be numbers that are chosen independently and uniformly at random from
{ 0, 1, . . . , n }. Let Z be their sum modulo n + 1. Show that X,Y, and Z are pairwise in-
dependent but not independent.

9. There are three gift boxes, two of them have stones, and one of them has gold. You have
to choose one of them. After your choice, I will open one box having stones (out of the
remaining two boxes). Now you hve a choice: either stay with your original choice or flip
your choice (choose the other unopened box). Which deterministic strategy is better: always
stay with your original choice or always flip your choice (or it makes no difference)? Now
consider a randomized strategy R(p) in which you flip your choice with probability p. Find
the optimal randomized strategy R(p).

10. Consider the following algorithm:

Random_Experiment(Integer n)
(1) Let the n−tuple I be given as I = ( j)nj=1 = (1, 2, . . . n − 1, n).
(2) Let R be a random permutation (with uniform probability) of I.
(3) Integer m = 0
(4) for i = 1 to n do
(5) if Ri > m
(6) m = Ri

Find the expected number of times the line (6) is executed as a function of n.

You might also like