Chris Pollett >
Old Classses >
CS255 |
HW1 Solutions PageAfter grading, I selected from amongst the better homeworks to post the solution below. The student or students that had their homework chosen received 1 bonus point a fter curving for having their homework selected. If you were chosen and would rather your homework not be used as the solution let me know and I will choose someone else's homework and they will receive the bonus point instead. The only changes I made were to convert the names listed in the homework files to SJSU student. No one solved problem 3 adequately, and as I said in class, the problem was harder than I intended, so I gave everyone a point. Below I give my solution which is tight up to a constant. Problem 3. Suppose we toss balls into one of `n` bins. Assume each bin is equally likely. Calculate with work the expected number of balls you would need to toss until there are two bins with at least two balls. Solution. Let our sample space `S` be sequences of ball tosses. Let `X` be the random variable which maps a particular sequence of ball tosses to the integer `n` at which two bins have at least two balls. We are asked to compute: `E[X] = sum_{i=1}^{infty} i \cdot Pr{X=i}.` We will show `E[X] = Theta(sqrt(n))`. To prove this we will show `E[X] gt 1/4 sqrt(n)` and `E[X] lt 7 sqrt(n)`. Claim 1. `E[X] gt 1/4 sqrt(n)`. Proof. We first note
Using the Taylor expansion of `ln(1 - x)`, we get Since `Pr{Y} gt 1/2`, `(\star\star\star)`, `(\star\star)`, and `(\star)` together imply the claim. Q.E.D. Claim 2. `E[X] lt 7 sqrt(n)`. Proof. First we note: Let `(#)` denote the sum on the right of the last line above. Now consider the random variable `X'(s)` which if the toss sequence `s` has two bins with two balls before the `2 + sqrt(n)`th toss is 0; otherwise, `X'(s) = X(s)`. It follows that:
The probability that a ball lands in 1 of these first `1+sqrt(n)` bins is at least `(1+sqrt(n))/n gt 1/sqrt(n)`. So by the same argument as we did for our second ball and question, we would expect a ball to land in one of these bins in at most `sqrt(n)` steps. After the first ball lands in one of these `1+sqrt(n)` bins, the odds that a second ball lands in one of the `sqrt(n)` remaining ins is `(sqrt(n))/n = 1/sqrt(n)`, so we would expect to get the second ball in at most `sqrt(n)` additional steps. Hence, |