# 随机算法 (Spring 2014)/Problem Set 1

## Problem 1

(Due to J. von Neumann.)

- Suppose you are given a coin for which the probability of HEADS, say , is
*unknown*. How can you use this coin to generate unbiased (i.e., ) coin-flips? Give a scheme for which the expected number of flips of the biased coin for extracting one unbiased coin-flip is no more than . - Devise an extension of the scheme that extracts the largest possible number of independent, unbiased coin-flips from a given number of flips of the biased coin.

## Problem 2

(Due to D.E. Knuth and A. C-C. Yao.)

- Suppose you are provided with a source of unbiased random bits. Explain how you will use this to generate uniform samples from the set . Determine the expected number of random bits required by your sampling algorithm.
- What is the
*worst-case*number of random bits required by your sampling algorithm (where the worst case is taken over all random choices)? Consider the case when is a power of , as well as the case when it is not. - Solve (1) and (2) when, instead of unbiased random bits, you are required to use as the source of randomness uniform random samples from the set ; consider the case when is a power of , as well as the case when it is not.

## Problem 3

We play the following game:

Start with people, each with 2 hands. None of these hands hold each other. At each round, uniformly pick 2 free hands and let these two hands hold together. Repeat this until no free hands left.

- What is the expected number of cycles made by people holding hands with each other at the end of the game? (One person with left hand holding right hand is also counted as a cycle.)

## Problem 4

In *Balls-and-Bins* model, we throw balls independently and uniformly at random into bins, then the maximum load is with high probability.

The *two-choice paradigm* is another way to throw balls into bins: each ball is thrown into the least loaded of 2 bins chosen independently and uniformly at random and breaks the tie arbitrarily. The maximum load of two-choice paradigm is with high probability, which is exponentially less than the previous one. This phenomenon is called the *power of two choices*.

Now consider the following three paradigms:

- The first balls are thrown into bins independently and uniformly at random. The remaining balls are thrown into bins using two-choice paradigm.
- The first balls are thrown into bins using two-choice paradigm. The remaining balls are thrown into bins independently and uniformly at random.
- Assume all balls are in a sequence. For every , if is odd, we throw th ball into bins independently and uniformly at random, otherwise, we throw it into bins using two-choice paradigm.

What is the maximum load with high probability in each of three paradigms. You need to give an asymptotically tight bound (i.e. ).

## Problem 5

Consider a sequence of flips of an unbiased coin. Let denote the absolute value of the excess of the number of HEADS over the number of TAILS seen in the first flips. Define . Show that , and that .