Combinatorics – Find Number of Pairs of Two Consecutive Zeros

binarycombinatorics

the problem

We call a binary sequence of length $n$ a string with $n$ digits of $0$ or $1$. For such a sequence, $A$,
of finite length,$f(A)$ represents a transformation where every 1 in $A$ becomes $0,1$ and every $0$
of $A$ becomes $1,0$. e.g $f((1,0,1))=(0,1,1,0,0,1)$ Find the number of pairs of two
consecutive zeros from $f^{(n)}((1))$, where $f^{(n)}((A))$ is the sequence obtained by transforming $A$ $n$ times.

my idea

I think first of all we should try some values for $n$ and try finding a rule

value of n how A looks like
0 1
1 0,1
2 1,0,0,1
3 0,1,1,0,1,0,0,1
4 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1

As we can see I think if we have a zero and a one consecutivly we can make a pair of 3 consecutive zero. Although this pair will be destroyed next transformation.

I don't know what to do forward! Hope one of you can help me! Thanks!

Best Answer

Here is a full solution. First of all, note that your sequence of strings is very similar to the Thue-Morse sequence. The only difference is that, if $n$ is even, a string in your sequence is inverted ($0$s become $1$s, and vice versa). Similar to the Thue-Morse sequence, your sequence can be constructed in a similar way. To get a $n+1$-st string one should take an $n$-th string and add an inverted $n$-th string to the beginning of it.

We will prove that by induction. The first string transformation $1\to01$ respects this rule. Consider a string $\overline ss$, which was transformed from $s$. (We denote a string where $1$s are substituted by $0$s and vice versa by $\overline s$.) What will happen next? The right half of $\overline ss$, which is $s$, will becomes $\overline ss$, as we already know. The left half $\overline s$ is inverted $s$, and since the rules $0\to 10$ and $1\to 01$ are inversions of each other, $\overline s$ will become $s\overline s$. Hence, $\overline ss$ will become $s\overline s\overline ss$, just as we wanted to prove.

This means that all substrings $00$ are preserved when go to the next string, also all $11$s become $00$s in the first half of the new string, too. And there can be one more $00$ in the place of concatenation. It is easy to see, that for even $n$ a string begins and ends in $1$. And for odd $n$ a string begins by $0$ and ends by $1$. So there appears one more $00$ when we go from an odd string to the next one.

Let us denote the number of $00$s in the $n$-th string by $a_n$, the number of $11$s in the $n$-th string by $b_n$ ($n$ is the number of a string as in the OP’s table, or the number of transformations). Then the following is true (for $n\ge0$):

$$\begin{align} a_{n+1}&=a_n+b_n+e_n\\ b_{n+1}&=a_n+b_n,\end{align}$$

where $e_n$ is $1$ if $n$ is odd, and $0$ otherwise. In other words, $e_n=\frac12+\frac12(-1)^{n-1}$. One can see that the following is true for $a_n$, $b_n$ (for $n\gt0$):

$$\begin{align} a_{n+1}&=2a_n+(-1)^{n+1}\\ b_{n+1}&=2b_n+1-e_n.\end{align}$$

Indeed, we have $$a_{n+1}=a_n+b_n+e_n=a_n+(a_n-e_{n-1})+e_n=$$ $$=2a_n-\frac12-\frac12(-1)^{n-2}+\frac12+\frac12(-1)^{n-1}=2a_n+(-1)^{n-1}.$$

The second equation is not really needed for our goal. But we can see, that $$b_{n+1}=a_n+b_n=(b_n+e_{n-1})+b_n=2b_n+1-e_n.$$

Now we just have to “solve” the recursion for $a_n$. If the equation were homogeneous, then the solution would be $a_n=k\cdot2^n$. The particular solution of the non-homogeneous equation has a form $l\cdot(-1)^n$. Putting this into the equation we get $$l\cdot(-1)^{n+1}=2l\cdot(-1)^n+(-1)^{n+1}.$$

Dividing by $(-1)^n$ we get $l\cdot(-1)=2l+(-1)$, so $l=\frac13$. Hence $a_n=k\cdot 2^n+\frac{(-1)^n}3$ for some $k$. Knowing that $a_1=0$ we find: $$0=k\cdot2-\frac13.$$

So, $k=\frac16$. And finally, for $n\gt0$: $$\boxed{a_n=\frac{2^{n-1}+(-1)^n}3.}$$

Out of curiosity, we can find $b_n$:

$$b_n=a_{n}-e_{n-1}=\frac{2^{n-1}+(-1)^n}3-\frac12-\frac12(-1)^{n}=$$

$$=\frac{2^{n-1}-\frac32-\frac12(-1)^n}3.$$

Related Question