MathLabs

Problem 5

The Bank of Bath issues coins with an HH on one side and a TT on the other. Harry has nn of these coins arranged in a line from left to right. He repeatedly performs the following operation: if there are exactly k>0k>0 coins showing HH, then he turns over the kkth coin from the left; otherwise all coins show TT and he stops. For example, if n=3n=3, the process starting with THTTHT is THT→HHT→HTT→TTTTHT\to HHT\to HTT\to TTT, which stops after three operations. (a) Show that, for each initial configuration, Harry stops after a finite number of operations. (b) For each initial configuration CC, let L(C)L(C) be the number of operations before Harry stops. Determine the average value of L(C)L(C) over all 2n2^n possible initial configurations.
Step 5 of 6: Average the two branches
In plain words

The last coin is equally likely to be a tail or a head.

En=12En−1+12(En−1+n)=En−1+n2E_n=\frac12E_{n-1}+\frac12(E_{n-1}+n)=E_{n-1}+\frac n2
Detailed analysis

Exactly half of the 2n2^n configurations end in TT and half in HH. The two preceding cases prove termination for every configuration and give En=12En−1+12(En−1+n)=En−1+n2E_n=\frac12E_{n-1}+\frac12(E_{n-1}+n)=E_{n-1}+\frac n2.