[Math] How many binary strings of length $n$ with no two adjacent 1’s and four more 0’s than 1’s

combinatoricscombinatorics-on-words

I want to count the number of binary strings which meet the following three conditions:

  • The number of $0$s is exactly four more than the number of $1$s.
  • There are no two adjacent $1$s.
  • The string does not start and end with a $1$. So, for instance, $001001001001$ is acceptable, but $10000001$ isn't.

How many strings of length $n$ meet those conditions?

Best Answer

HINT: Suppose that there are $k$ ones. Then there are $k+4$ zeroes, so $n=2k+4$. In particular, $n$ must be even, so if $a_n$ is the number of acceptable strings of length $n$, then $a_n=0$ when $n$ is odd. Now it’s just a matter of counting the ways to place $k$ ones in a string of length $2k+4$ in such a way that no two of them are adjacent, and at least one of the end characters is a zero.

Think of the ones as dividers; your task is to distribute the $k+4$ zeroes in the $k+1$ spaces before, between, and after the ones in such a way that each of the $k-1$ internal spaces gets at least one zero, and at least one of the end spaces gets a zero. This is a slight variation of a standard stars and bars problem.

  • First determine how many ways there are to distribute the $k+4$ zeroes so that each of the $k+1$ spaces except the last gets at least one of them.
  • Then determine how many ways there are to distribute the $k+4$ zeroes so that each of the $k+1$ spaces except the first gets at least one of them.
  • Then determine how many ways there are to distribute the zeroes amongst the $k-1$ internal spaces so that each of these spaces gets at least one of them.
  • Then combine these results appropriately.