Let $X$=The number of trials until one of the urns is empty. We want to find the distribution of X. We know that $X$ must be at least $n$ and at most $2n-1$.
$$P(X=n)=2\left(\dfrac{1}{2}\right)^n$$
$$P(X=n+1)=2\left[ {n \choose n-1}\left(\frac{1}{2}\right)^{n-1}\left(\frac{1}{2}\right)\cdot \left(\frac{1}{2}\right)\right] = 2 \left[{n \choose n-1}\left(\frac{1}{2}\right)^{n+1} \right]$$
Continuing this we find that
$$P(X=x) = 2\left[ {x-1 \choose n-1}\left(\frac{1}{2}\right)^x \right], \;x \in \{n,n+1,...,2n-1\}$$
We need to find the expected value of $X$ because the answer to the problem (what is the expected number of ball in the remaining urn) is $2n - E(X)$. I wasn't able to find a closed form for $E(X)$. If we let $Y=X-n$ then we get that
$$ P(Y=y)=2{n+y-1 \choose n-1}\left(\frac{1}{2} \right)^{n+y} = 2{n+y-1 \choose y}\left(\frac{1}{2} \right)^{n+y}, \; y \in \{0,1,...,n-1\} $$
I thought it would be easier to find $E(Y)$ because $Y$ ranges from $0$ to $n-1$ versus $X$ which ranges from $n$ to $2n-1$ but I still wasn't able to come up with a closed form. If you could, then $E(X) = E(Y)+n$ and the answer to the original problem would be $2n- E(X) = n - E(Y)$.
r's and $k$b's exist? How many sequences of pulling balls end after exactly $n+k$ turns? How many balls are left in the non-empty urn if it ended after $n+k$ turns? What is the definition of expected value? – JMoravitz Sep 07 '17 at 04:20