Expected length of time before one of two basketball players makes a basket Question: Two boys play basketball in the following way. They take turns in shooting and stop when a basket is made. Player A goes first and has a probability $p_1$ of making a basket. Player B goes second and has probability $p_2$ of making a basket. Assume that the successive trials are independent. Find the probability distribution of the total number of attempts.
a) What is the expected number of attempts?
b) Also find the probability that A wins.
My attempt:
Let X be the total number of attempts. Clearly, X is odd if A wins, and even if B wins. 
Now,$P(X=2k+1)=(1−p_1)^k(1−p_2)^kp_1$ (as X=2k+1 means that the first k attempts
by both A and B fail, then A succeeds), 
and $P(X = 2k) = (1 − p_1)^k(1 − p_2)^{k−1}p_2$
But now I've got no idea how to get the expectation from here, I have the answer but it doesn't make any sense.
 A: We use a conditional expectation argument.  Let $c$ be the expected number of attempts. 
If Boy A hits on his first try (probability $p_1$), the number of attempts, and hence the expected number of attempts, is $1$.
If Boy A misses on the first attempt, and B hits on his first (probability $(1-p_1)p_2$) then the expected number of attempts is $2$.
If they both miss their first attempts, then two attempts have been used up, and the expected additional number of attempts is $c$. Thus
$$c=(p_1)(1)+(1-p_1)(p_2)(2)+(1-p_1)(1-p_2)(2+c).$$
Solve this linear equation for $c$.
Remark: The probability Boy A (ultimately) wins can also be found by a conditioning argument. However, since you have already obtained an expression for $\Pr(X=2k+1)$, we can simply sum this from $k=0$ to $\infty$. The series is an infinite geometric series.
A: Disclaimer: I bet I messed up somewhere.
For notational convenience, let $q_i = 1 - p_i$, $i = 1, 2$.
Let's do some pattern investigation.
The probability of the first attempt being successful is $p_1$.
The probability of the second attempt being successful is $q_1p_2$ (assuming all previous attempts were not successful, which we assume from here on for each case).
The probability of the third attempt being successful is $q_1q_2p_1$.
The probability of the fourth attempt being successful is $q_1^2q_2p_2$.
The probability of the fifth attempt being successful is $q_1^2q_2^2p_1$.
The probability of the sixth attempt being successful is $q_1^3q_2^2p_2$.
In general, if we let $X$ be the total number of attempts,
$$\mathbb{P}(X = k) = \begin{cases}
q_1^{(k-1)/2} q_2^{(k-1)/2}p_1 &\text{ if } k \text{ odd} \\
q_1^{k/2} q_2^{k/2-1}p_2 &\text{ if } k \text{ even}
\end{cases}\text{ , } k \geq 1\text{.}$$
The expected value is given by
$$\begin{align}
\mathbb{E}[X] &= \sum_{k\text{ odd}}kq_1^{(k-1)/2} q_2^{(k-1)/2}p_1  +  \sum_{k\text{ even}}kq_1^{k/2} q_2^{k/2-1}p_2 \\
&= (1p_1 + 3q_1q_2p_1 + 5q_1^2q_2^2p_1 + \cdots) + (2q_1p_2 + 4q_1^2q_2p_2 + 6q_1^3q_2^2p_2 + \cdots) \\
&= p_1\left(1+3q_1q_2 + 5q_1^2q_2^2 + \cdots \right) + 2q_1p_2\left(1+ 2q_1q_2 + 3q_1^2q_2^2 + \cdots\right)\text{.}
\end{align}$$
Recall that the infinite sum
$$\sum_{i=0}^{\infty}x^i = \dfrac{1}{1-x} = 1+ x + x^2 + \cdots\text{, } |x| < 1\text{.}$$
Then differentiating, we have
$$1 + 2x + 3x^2 + \cdots = \dfrac{1}{(1-x)^2}\text{, }|x| < 1\text{.}$$
Assuming $|q_1q_2|< 1$, 
$$1+ 2q_1q_2 + 3q_1^2q_2^2 + \cdots =1+ 2q_1q_2 + 3(q_1q_2)^2 + \cdots = \dfrac{1}{(1-q_1q_2)^2}\text{.}$$
Now as for the other sum, 
$$1+3q_1q_2 + 5q_1^2q_2^2 + \cdots $$
I use the results here with $a = 1$, $d = 2$, $r = q_1q_2$. You can see the proof at the link above for computing $S_n$ and take $n \to \infty$ to get the formula here, which ends up being
$$1+3q_1q_2 + 5q_1^2q_2^2 + \cdots  = \dfrac{1}{1-q_1q_2}+\dfrac{2q_1q_2}{(1-q_1q_2)^2}\text{.}$$
The probability that $A$ wins is equivalent to the probability of $k$ being odd, or $$\sum_{k\text{ odd}}q_1^{(k-1)/2} q_2^{(k-1)/2}p_1 = p_1(1+q_1q_2 + q_1^2q_2^2 + \cdots) = \dfrac{p_1}{1-q_1q_2}$$
since $|q_1q_2| < 1$ and we have the infinite geometric series, as mentioned earlier.
