1
$\begingroup$

Consider a binary string of length $n$ that starts with a $1$ and ends in a $0$. Clearly there are $2^{n-2}$ such bit strings. I would like to condition these sequences by insisting that the number of ALL $1$s to the left of any $0$ is a power of $2$, i.e. $1, 2, 4, 8, 16, \dots$ (you can call these binary partitions).

For example, when $n=5$ here is the complete listing: $10000, 10010, 10100, 11000, 11110$.

When $n=6$: $100000, 100010, 100100, 101000, 101110, 110000, 110110, 111100$.

QUESTION. Is it possible to find a formula for their enumeration, for each $n$? Or, perhaps a generating function? A recurrence?

The count of the first few, for $n\geq2$, is: $1, 2, 3, 5, 8, 12, 17, 24, 34, 48, 67, 92, 124, 164, 213, \dots$

$\endgroup$
5
  • $\begingroup$ @T.Amdeberhan Do you mean the ones immediately to the left of any $0$ or are you referring to all $1$s that appear somewhere to the left of the zero in that string? $\endgroup$ Commented Jun 21 at 16:47
  • $\begingroup$ @BenGrossmann: I edited again to read ALL 1's. $\endgroup$ Commented Jun 21 at 16:55
  • 1
    $\begingroup$ Okay, so you really want to include, when $n=6,$ the value $101110?$ I guess I misread the question. TThe case $n=5$ is too limited to show what you meant, then. $\endgroup$ Commented Jun 21 at 17:09
  • $\begingroup$ Yes, this is correct. $\endgroup$ Commented Jun 21 at 17:10
  • $\begingroup$ The following entry in the Online Encyclopedia of Integer Sequences is like to be helpful: oeis.org/A129504 $\endgroup$ Commented Jun 21 at 18:25

1 Answer 1

2
$\begingroup$

If the total number of $1$ digits is $2^k,$ then we can group the ones digits as $1+1+2+4+\dots+2^{k-1}$ in $k+1$ places, with one zero after, and $n-2^k-1$ zeros out after $1,1,2,\dots,2^{k-1}.$ This is the number of non-negative integer solutions to:

$$x_1+x_2+\dots+x_{k+1}=n-2^k-1.$$ which is $\binom {n+k-2^k-1}{k}.$

For example, when $n=6$ and $k=2,$ we get strings of the form:

$$10^*10^*110^*0$$ To make the string of length $6,$ we need one more zero, other than the one at the end, so there are $3$ ways to place that one zero.

So you function is:

$$f(n)= \sum_{2^k<n} \binom{n+k-2^k-1}{k}$$

When $n=5,$ this gives:

$$\binom{5-2}{0}+\binom{5-2}{1}+\binom{2}{2}=1+3+1=5.$$

When $n=6,$ you get:

$$\binom{4}{0}+\binom{4}1+\binom{3}{2}=8.$$

I doubt this will have a closed form.


The function grows faster than polynomial time, since, for $n>2^k,$ $f(n)>\binom{n+k-2^k-1}{k}.$ which is a polynomial of degree $k$ in $n.$

We get an easy upper bound $f(n)<2^{n-2}.$ It might be interesting to compute $\limsup \frac{\log f(n)}{n}.$ I can't see that, but I would not be surprised if it was $0.$


If $f(n)$ is our function, then I think we get a generating function:

$$F(x)=\sum_{n=0}^\infty f(n)x^n=\sum_{k=0}^{\infty}\frac{x^{2^k+1}}{(1-x)^{k+1}}$$

Again, it seems unlikely this will have a closed form.

This does give us an interesting generalization, if $A=\{a_0<a_1<\dots\}$ is an infinite set of positive natural numbers and $f(n)$ is the number of $n$-bit numbers starting with $1$ and ending with $0$ such that the number of $1$s to the left of any $0$ is in $A,$ then:

$$\sum f(n)x^n=\sum_{k}\frac{x^{a_k+1}}{(1-x)^{k+1}}$$ and $$f(n)=\sum_{k, a_k<n}\binom{n+k-a_k-1}{k}$$

If $a_k=2k+1$ are the odd numbers:

$$\sum_n f(n)x^n = \frac{\frac{x^2}{1-x}}{1-\frac{x^2}{1-x}}= \frac{x^2}{1-x-x^2}$$

And we get that $f(n)=F_{n-1}$ where $F_k$ is the $k$th Fibonacci number.

$\endgroup$
1
  • $\begingroup$ This is a wonderful analysis. $\endgroup$ Commented Jun 21 at 19:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .