Artificial intelligent assistant

Andrei flips a coin over and over again until he gets a tail followed by a head, then he quits. What is the expected number of coin flips? (a) Andrei flips a coin over and over again until he gets a tail followed by a head, then he quits. What is the expected number of coin flips? (b) Bela flips a fair coin over and over again until she gets two tails in a row, then she quits. What is the expected number of coin flips? Hello, I have been having some trouble with this problem. I have tried to use state diagrams, but bonked my head on the table, because obviously, that wouldn't work. I have not yet been able to find any method in doing this. Any help is appreciated

In the first case ( **a** ) the sequence of the outcomes is something like $H^j T^k H$ with $j\geq 0$ and $k\geq 1$. Such a sequence has length $j+k+1$, hence the expected number of coin flips is given by: $$\sum_{j\geq 0}\sum_{k\geq 1}\frac{j+k+1}{2^{j+k+1}}=\sum_{h,k\geq 1}\frac{h+k}{2^{h+k}}=4.$$ In the second case ( **b** ), the sequence of outcomes is a string over $\\{H,TH\\}$ plus a $TT$ suffix. The number of strings of length $N$ over $\Sigma=\\{H,TH\\}$ is given by the $(N+1)$-th Fibonacci number $F_{N+1}$, hence the expected number of coin flips is given by: $$ 2+\sum_{N=0}^{+\infty}\frac{N\cdot F_{N+1}}{2^{N+2}}=6.$$

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 4757dc78a2fa6c681335fca339226a7b