Please explain briefly Consider the following recursive algo
Please explain briefly?
Consider the following recursive algorithm TiireeHeadsOrThreeTails, which takes as input a positive integer k: Algorithm ThreeHeadsOrThreeTails(A:): // all coin flips made are mutually independent flip a fair coin three times; if the result is HHH or TTT then return k else ThreeHeadsOrThreeTails(A; + 1) endif You run algorithm ThreeHeadsOrThreeTails(I), i.e., with k = Define the random variable X to be the value of the output of this algorithm. What is the expected value of XISolution
When a fair coin is tossed 3 times, sample space would be
having 2 cube = 8 events.
P(HHH, TTT) = 2/8 = 0.25
Prob for other outcomes = 0.75
Hence this is binomial with expected value = np
= 0.25 n where n is the no of trials.
