Extracting balls from a basket until all have the same colour Consider a basket containing $n$ red and $m$ blue balls. At each step choose a (random) ball in the basket and put it out. Keep doing this until all the (remaining) balls have the same color. Let $X$ be the number of remaining (mono-colored) balls. What is $\mathbb{E}[X]$ ?
 A: This problem can be well approached from the opposite direction.
First, let $Y$ be the number of same-colored balls left in the basket at the end of the process. Then $\mathbb{E}[X]=m+n-\mathbb{E}[Y]$.
Now imagine that we have taken all the balls out, and we are putting them back in in the same order that we took them out. Then $Y$ is just the number of balls of the same color that we put in consecutively from the beginning.
Assuming that there is at least one ball, we can put in the first ball with no constraints, but after that all the balls must be the same color as the first. The probability of the first ball being red is $\frac{n}{n+m}$, while the probability that it is blue is $\frac{m}{n+m}$. If we let $R$ and $B$ be respectively the number of consecutive red balls and blue balls which are chosen from the total remaining balls (that is $n+m-1$ balls), we get:
$$\mathbb{E}[Y]=1+\frac{n}{n+m}\mathbb{E}[R]+\frac{m}{n+m}\mathbb{E}[B]$$
Now we will turn to the results of a previous math stack exchange question, Expected number of draws until the first good element is chosen, which tells us $\mathbb{E}[R]=\frac{n-1}{m+1}$ while $\mathbb{E}[B]=\frac{m-1}{n+1}$.This gives:
$$\mathbb{E}[Y]=1+\frac{n}{n+m}\frac{n-1}{m+1}+\frac{m}{n+m}\frac{m-1}{n+1}=\frac{n}{m+1}+\frac{m}{n+1}$$
Finally, we have $\mathbb{E}[X]=m+n-\mathbb{E}[Y]=m+n-\frac{n}{m+1}-\frac{m}{n+1}$.
A: Let us find the the expectation for blue balls remaining. The number of blue balls left in the container are the balls placed after the last red ball. Let $X_i$ denote an IRV if blue ball $i$ is placed after the last red ball. There are $n$ red balls and therefore, $n+1$ slots for the blue ball to go in. Therefore, $E(X) = \sum E(X_i) = \sum_{i=1}^{i=m} \frac{1}{n+1} = \frac{m}{n+1}$. Doing the same analysis for red gives us the total expectation as $\frac{n}{m+1} + \frac{m}{n+1}$
