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

## Problem 1

• (Due to von Neumann) Suppose that you are given a coin for which the probability of HEADS, say ${\displaystyle p}$, is unknown. How can you use this coin to generate unbiased (i.e., ${\displaystyle \Pr[\mathrm {HEADS} ]=\Pr[\mathrm {TAILS} ]=1/2}$) 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 ${\displaystyle {\frac {1}{p(1-p)}}}$.
• (Due to Knuth and Yao) Supposed you are provided with a source of unbiased random bits. Explain how you will use this to generate uniform random samples from the set ${\displaystyle [n]=\{0,1,\ldots ,n-1\}}$. Determine the expected number of bits required by your sampling algorithm. What is the worst-case number of bits required by your sampling algorithm (where the worst-case is taken over all random choices of unbiased random bits)? Consider the case when ${\displaystyle n}$ is a power of 2, as well as the case when it is not.

## Problem 2

We play the following game:

Start with ${\displaystyle n}$ 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 (one person with left hand holding right hand is also counted as a cycle) at the end of the game?

(Hint: Consider how to count the number of cycles using indicator random variables.)

## Problem 3

For any ${\displaystyle \alpha \geq 1}$, a cut ${\displaystyle C}$ in an undirected graph ${\displaystyle G(V,E)}$is called an ${\displaystyle \alpha }$-min-cut if ${\displaystyle |C|\leq \alpha |C^{*}|}$ where ${\displaystyle C^{*}}$ is a min-cut in ${\displaystyle G}$.

Give an analysis to lower bound the probability that a single iteration of Karger's Random Contraction algorithm returns an ${\displaystyle \alpha }$-min-cut in a graph ${\displaystyle G(V,E)}$ of ${\displaystyle n}$ vertices.

• 新增如下的一个问题。

Use the above bound to estimate the number of distinct ${\displaystyle \alpha }$-min cuts in ${\displaystyle G}$.

## Problem 4

 Freivalds' Theorem Let ${\displaystyle A}$ be an ${\displaystyle n\times n}$ matrix such that ${\displaystyle A\neq {\boldsymbol {0}}}$. For a uniformly random ${\displaystyle r\in \{0,1\}^{n}}$, ${\displaystyle \Pr[Ar={\boldsymbol {0}}]\leq {\frac {1}{2}}}$.
 Schwartz-Zippel Theorem Let ${\displaystyle f\in \mathbb {F} [x_{1},x_{2},\ldots ,x_{n}]}$ be a multivariate polynomial of degree ${\displaystyle d}$ over a field ${\displaystyle \mathbb {F} }$ such that ${\displaystyle f\not \equiv 0}$. Fix any finite set ${\displaystyle S\subset \mathbb {F} }$, and let ${\displaystyle r_{1},r_{2}\ldots ,r_{n}}$ be chosen uniformly and independently at random from ${\displaystyle S}$. Then ${\displaystyle \Pr[f(r_{1},r_{2},\ldots ,r_{n})=0]\leq {\frac {d}{|S|}}.}$

Prove that the Freivalds Theorem is a special case of the Schwartz-Zippel Theorem.

## Problem 5

Consider the following two schemes of throwing ${\displaystyle m}$ balls into ${\displaystyle n}$ bins:

• BiB (balls-into-bins):
for i=1 to m do:
choose r uniformly and independently from [n];
put ball-i into bin-r;


When ${\displaystyle m=\Theta (n)}$, the maximum load is ${\displaystyle \Theta \left({\frac {\ln n}{\ln \ln n}}\right)}$ with high probability.

• P2C (power-of-two-choices):
for i=1 to m do:
choose r1 and r2 uniformly and independently from [n];
if bin-r1 has fewer balls than bin-r2
put ball-i into bin-r1;
else
put ball-i into bin-r2;


When ${\displaystyle m=\Theta (n)}$, the maximum load is ${\displaystyle \Theta \left(\ln \ln n\right)}$ with high probability.

Questions: Assume ${\displaystyle n}$ balls are thrown to ${\displaystyle n}$ bins on after another.

1. If we throw the first ${\displaystyle {\frac {n}{2}}}$ balls as BiB and then throw the rest balls as P2C, what is the asymptotic maximum load with high probability?
2. If we throw the first ${\displaystyle {\frac {n}{2}}}$ balls as P2C and then throw the rest balls as BiB, what is the asymptotic maximum load with high probability?
3. If we throw each even numbered ball as BiB and each odd numbered ball as P2C. What is the asymptotic maximum load with high probability?