Permutations

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

PERMUTATION STRINGS Jeffrey A.

Barnett1

Problem: What is the length of the shortest string on an alphabet of n


symbols that contains all n! permutations of the alphabet as (contiguous)
substrings?

Partial Solution: Minimum length strings for n = 1, 2, 3 are, respec-


tively, 1, 121, and 123121321. Their lengths are 1 = 1, 3 = 1! + 2!, and
9 = 1!+2!+3!. Given any string that contains all permutations of an alphabet
of n − 1 symbols, a new string containing all permutations of n symbols can
be generated by the following procedure: replace each of the (n − 1)! permu-
tations of the form j1 . . . jn−1 with the string j1 . . . jn−1 nj1 . . . jn−1 . Overlaps
among permutations in the old string are maintained in the replacements and
each of the (n − 1)! replaced strings grows in length by n symbols. Therefore,
the new string is n! = n × (n − 1)! symbols longer than the old string. The
following depicts the construction as discussed for transforming the upper-
bound solution from n = 3 to n = 4. Note, the output substrings, e.g.,
1234123, contain all permutations of their first four characters.

123 1234123
231 2314231
312 3124312
213 2134213
132 1324132
321 3214321
--------- ---------------------------------
123121321 => 123412314231243121342132413214321

A simple induction argument establishes the fact that U (n) = ni=1 i! is


P

an upper bound on the necessary string length. Further, n! is clearly a lower


bound. Note, (U (n) − n!)/n! ≈ 1/n so the order of magnitude is correct. I
conjecture, but cannot prove that U (n) is the solution to the stated problem.

1
[email protected]

You might also like