Back
1 . Consider the following recursive algorithm THREEHEADSORTHREETAILS, which takes as input a positive integer k:

Algorithm THREEHEADSORTHREETAILS(k):
flip a fair coin three times;
if the result is HHH or TTT
then return k
else
THREEHEADSORTHREETAILS(k+1)
endif

You run algorithm THREEHEADSORTHREETAILS(1), i.e., with k=1. Define the random variable X to be the value of the output of this algorithm. What is the expected value of X?
(a)
5
(b)
3
(c)
4
(d)
2