Wednesday, November 17, 2010

Combinations of H and T

One of the very popular brain teasers:
What's the mean number of coin toss to get HH/HT/HHH...ect?

Approach 1: Considering absorption state of a Markov chain -> solving a system of simultaneous equation

Approach 2: Recursive formulae. For example, let H = expected number of tosses to get a head, HH = expected number of tosses to get two consecutive heads and so on. Then
H = 0 + 0.5*1 + 0.5*(1+H); T = 0 + 0.5*1 + 0.5*(1+T)
HH = H + 0.5*1 + 0.5*(1+HH)

HT = H + 0.5*1 + 0.5*(1+T)

HTH = HT + 0.5*1 + 0.5*(1+HTH)

HHT = HH + 0.5*1 + 0.5*(1+T)

See here for more interview questions/brainteasers

No comments:

Post a Comment