Find expected tosses to see a coin pattern
Problem: Expected Tosses for a Coin Pattern
A fair coin is tossed repeatedly until a specific target pattern, of length 3, appears as a consecutive substring of the sequence of tosses.
For example, if the target pattern is HHH, the process stops as soon as HHH is observed. If the target is HTH, it stops upon HTH.
Tasks:
- Describe a general method or algorithm to compute the expected number of tosses required to observe any given target pattern.
- Using your described method, compute the expected number of tosses for the specific patterns:
HHHHTH
AI interview prep
Core dilemma
The central engineering challenge is accurately modeling and calculating expected values in a probabilistic system where past events (partial pattern matches) directly influence future probabilities, specifically accounting for pattern overlaps.
2 tradeoffs and 2 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Find expected tosses to see a coin pattern
Problem: Expected Tosses for a Coin Pattern
A fair coin is tossed repeatedly until a specific target pattern, of length 3, appears as a consecutive substring of the sequence of tosses.
For example, if the target pattern is HHH, the process stops as soon as HHH is observed. If the target is HTH, it stops upon HTH.
Tasks:
- Describe a general method or algorithm to compute the expected number of tosses required to observe any given target pattern.
- Using your described method, compute the expected number of tosses for the specific patterns:
HHHHTH