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 6 of 6: Solve the recurrence
In plain words

Add the successive increments from one coin up to n coins.

En=∑j=1nj2=n(n+1)4E_n=\sum_{j=1}^{n}\frac j2=\frac{n(n+1)}4
Detailed analysis

Iterating the recurrence from E0=0E_0=0 (or from the base case) gives En=∑j=1nj2=n(n+1)4E_n=\sum_{j=1}^{n}\frac j2=\frac{n(n+1)}4. This is the required average, and the induction simultaneously proves finite termination for every initial configuration.