4

Let there be a sequence $a_1, a_2, a_3,...,a_n$ that represent some actions that you know are required to solve a problem. However, you do not know what order these actions need to be taken to solve that problem, but you know that all of them are required at some point. What is the shortest such sequence $S$ of actions with length $m$ in terms of $n$ such that all permutations of the actions are contained within $S$ with gaps and overlaps permissible?

Example:

Let's say you know that 3 steps are required to fix your computer, but you don't know in what order:

  1. Restarting a program.
  2. Installing a different program.
  3. Run antivirus.

So one sequence containing all permutations $(123,132,213,231,312,321)$ guaranteed would be $S=123\ 123\ 123$ (meaning $m$ has a guaranteed upper bound of $n^2$ if we extrapolate) but a shorter sequence would be $S=1231231$ (which I am not sure is of minimum length). How can we generate this minimum sequence?

pqn
  • 145

1 Answers1

1

[Having looked into this more carefully, I've discovered that my answer is wrong. This is still an open problem, but bounds are given at http://oeis.org/A062714 . I will leave this answer up as a cautionary tale against being hasty.]

Unlike the other question you linked that only permits overlap, which is still an open question, I believe this one has a simple closed answer. Your example of permutations on $123$ is on the right track.

First, let me define an inversion of a permutation: From Wolfram, A pair of elements $(p_i,p_j)$ is called an inversion in a permutation $p$ if $i<j$ and $p_i>p_j$.

Call an inversion adjacent if $j = i + 1$ (that is, two elements are right next to each other, and the first one is greater). We will construct $S$ and show that how soon a permutation appears in $S$ depends on the number of adjacent inversions it has.

We can begin constructing $S$ by listing the elements of the sequence $a_1, a_2, a_3,...,a_n$ in order. (Let's say WLOG that every $a_i$ is the integer $i$, so this sequence is just $1 \ldots n$) The order at the beginning doesn't matter, but we know that there's no use in repeating elements so early, because these are just the beginnings of all possible permutations.

After that, the best thing to do is repeat the sequence $1 \ldots n$ another $n-2$ times, and append $1$ to the end. The reason for this is that when constructing permutations from $S$, we can pick the elements from from the first instance of $1 \ldots n$ until we hit an adjacent inversion. Then we must continue with the next instance of $1 \ldots n$. The only permutation to have $n-1$ adjacent inversions is the reverse permutation. Every other permutation has less. So it's sufficient to construct $S$ this way.

To prove that this is the shortest possible $S$, observe that if there are $j$ adjacent inversions occurring in a permutation before a given element (including an adjacent inversion in which it comes last), that element will be "skipped" $j$ times in our $S$, so we require that element to be in $S$ $j+1$ times. $1$ can have $n-1$ adjacent inversions before it (in the reverse permutation) and every other element can have $n-2$ adjacent inversions before it (by putting it at the end, and writing everything else in reverse order).

Thus $S$ has length $n^2 - n + 1$.

NoName
  • 3,025
  • 1
  • 17
  • 34
  • This doesn't disprove $n^2-n+1$, but another $S$ is 2123212. – Empy2 Apr 21 '15 at 16:42
  • 2123421234212 works. If you only have one 4, you need seven digits on either side to cover the six permutations that start, or end, with 4. – Empy2 Apr 21 '15 at 17:04
  • 1
    Reading over this again, I've discovered I'm wrong: this question is in fact a duplicate, because "subsequences" may skip over elements in the sequence, and this is still an open problem but there's a lower bound better than what I have, as shown at http://oeis.org/A062714 – NoName Apr 21 '15 at 17:13