Average number of keystrokes based on probability "A researcher in the rain forest has left his laptop unattended
and a curious monkey has come to investigate. When the researcher
looks up from the plant he is studying he sees the monkey at
the keyboard. He makes threatening noises as he runs back. Assume
that every time he shouts there’s a 50% chance that he will manage to
disrupt the monkey before it makes another key stroke, and that he will
have reached the laptop before he has shouted six times. What do you think
is the average number of key strokes the monkey will manage in this
situation?"
How should I approach this problem using basic counting and probability formulas?
The answer is 31/32, but I don't know how to get to this result.
A tree diagram is suggested for this problem.
 A: Method I (Indicator Variables) Let $X_i$, for $i=1,\cdots, 5$ be the indicator variable for the $i^{th}$ possible key stroke.  Then $E=E[\sum X_i]=\sum E[X_i]$.  But $E[X_i]=\frac 1{2^i}$ so the answer is $$E=\frac 12+\frac 14+\frac 18+\frac 1{16}+\frac 1{32}=\frac {16+8+4+2+1}{32}=\frac {31}{32}$$
Note:  if it takes our man $N$ shouts to get back the above shows that the answer is $\frac {2^{N-1}-1}{2^{N-1}}$
Method II:  (Direct Calculation).  There are six possible outcomes:  namely, $0,1,2,3,4,5$ key strokes.  Let $p_i$ be the probability of outcome $i$.  Then $p_0=\frac 12$, as there is a $50-50$ chance the first shout works.  Similarly $p_1=\frac 14$ as to get this outcome you need the first shout to fail and the second to work.  Continuing in this spirit we see that $p_i=\frac 1{2^{i+1}}$ for $i=0,1,2,3,4$ and $p_5=\frac 1{32}$ Thus our answer is $$E=\sum_{i=0}^5 i\times p_i=0\times \frac 12+1\times \frac 14+2\times \frac 18+3\times \frac 1{16}+4\frac 1{32} + 5\times \frac 1{32}$$$$=\frac {0+1\times 8+2\times 4+3\times 2+4+5}{32}$$ $$=\frac {8+8+6+4+5}{32}=\frac {31}{32}$$
Note:  Comparing the two methods gives a strong argument in favor of the indicator variables!  For example, while perfectly possible it's a lot more work to extend to $N$ shouts via method II.
