6
$\begingroup$

I have a question about binary strings with a certain property:

Given an integer $n$-bit integer $p$, that is not a perfect power of $2$. Count the number of $(p+n-2)$-bit strings that have the property that they start with $\underbrace{00...01}_{n-bit}$ and end with $\underbrace{100...0}_{n-\mathrm{bit}}$ and each $n$-bit substring occurs exactly once.

E.g., for $n=3$, $p=7$ there are $001 01 100$ and $001 10 100$, which are the only ones for the pair $(n,p)$.

Further examples are: $n=5$ and $p=29$: $00001 0001101001111011100101 10000$

and $n=5$ and $p=19$: $00001 101011110010 10000$.

I searched for related work and found papers about incompressible strings and Kolmogorov complexity. However, they did not helped me out.

Does there exists a combinatorial approach to count the number of solutions? Or is there an heuristic argument that gives a good approximation?

$\endgroup$
2
  • $\begingroup$ The requirement that each possible substring of a certain length occurs exactly one is like the requirement of Lyndon words. Maybe you are looking for something that could be derived easily from the study of Lyndon words. $\endgroup$
    – mikero
    Jun 20, 2011 at 15:22
  • $\begingroup$ @mikero this could very well be an answer :) $\endgroup$ Jun 20, 2011 at 15:52

1 Answer 1

8
$\begingroup$

You mean that each nonzero n-bit substring occurs once, and the all-zero n-bit substring occurs no times, right? Essentially, what you are looking for is a De Bruijn sequence.

The number of de Bruijn sequences should be in OEIS somewhere but I'm having trouble finding it. My guess is that it grows doubly exponentially, since it is the number of Hamiltonian cycles in an exponential sized graph (the de Bruijn graph) and graphs tend to have exponentially many such cycles when they have any.

$\endgroup$
1
  • $\begingroup$ Thanks David, this indeed looks very close to answer i was looking for. However, the De Bruijn sequence demands that "every possible subsequence of length n in A appears as a sequence of consecutive characters exactly once." But i guess one could simply cut off each of these sequences at a earlier point to get all possible shorter sequences :) $\endgroup$
    – Etsch
    Jun 20, 2011 at 18:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.