Expected number of coin flips to get two consecutive heads
Analyze the expected number of coin flips to get two consecutive heads.
Examples
Input:"test_input_1"
Output:"output_1"
Input:"test_input_2"
Output:"output_2"
Hints
Consider using states to model the problem, where each state represents the number of consecutive heads obtained so far.
Let E₀ be the expected number of flips starting from 0 consecutive heads, and E₁ be the expected number starting from 1 consecutive head. Set up equations relating E₀ and E₁ based on possible outcomes of the next flip.
Solve the system of equations derived from the state transitions to find the expected number of flips starting from 0 consecutive heads.
Expected number of coin flips to get two consecutive heads
Analyze the expected number of coin flips to get two consecutive heads.