Discrete Mathematics North-Holland
141
117 (1993) 141-150
Universal cycles of k-subsets and k-permutations B.W. Jackson Deparrmenr
of Mathematics and Computer Science, San Jose State University, San Jose, CA 95192,
USA Received 28 August 1990 Revised 17 September 1991
Abstract Jackson, B.W., Universal 141-150.
cycles of k-subsets
and k-permutations,
Discrete
Mathematics
117 (1993)
In this paper the author constructs universal cycles of 3-subsets of an n-set for n 28 and (n, 3)= 1, verifying a conjecture of Chung et al. (1989) for 3-subsets. Universal cycles of 4-subsets of an n-set for n > 8 and (n, 4) = 1 are also constructed, partially solving the same conjecture for 4-subsets. Universal cycles of k-permutations are constructed for any k > 3 and n > k + 1.
1. Introduction A familiar combinatorial arrangement has come to be known as a de Bruijn cycle. particular a (binary) de Bruijn cycle of order k is defined to be a cycle (X1,X2,..., xzk), where each Xi = 0 or 1, and every possible binary sequence B of length k occurs uniquely as some k-block in this cycle, that is, B = (Xi+ 1, Xi + *, . . . , Xi +k) for some i (where index addition is performed modulo 2k). In this paper cyclic arrangements of the digits N = (0, 1, . . . , n - 1} which contain each k-combination (k = 3,4) or In
each k-permutation (k 3 3) exactly once will be constructed. We denote by (T) the set of all (i)=n(n1) ... (n-k+ 1)/k! k-combinations of the n-set N=(O, 1, . . . ,n-l}. If there is a cycle C=(X~,X~,...,X~~)), where each in (f) as a unique k-block, Xi=O, 1, ...) or n - 1, so that C contains each k-combination we say that C is a universal cycle of(f). If there exists a universal cycle of(c), then k and n must satisfy a simple modular condition. For a fixed i, each occurrence of i in C is contained in exactly k k-blocks. Since these k-blocks represent k-combinations of {O,l,...,n-1) w h ic h contain i, and there are exactly ({Ii) of these, then k divides (;I:), i.e., (;I:)=0 (modk). Correspondence to: B.W. Jackson, Department University, San Jose, CA 95192, USA. 0012-365X/93/$06.00
0
1993-Elsevier
of Mathematics
Science Publishers
and Computer
Science, San Jose State
B.V. All rights reserved
142
B. W. Jackson
Modular condition.
If there exists a universal
Chung et al. [2] have made the following a $100 reward).
cycle of (f), then (I: I :) = 0 (mod k). conjecture
(for which they are offering
Conjecture. For every k>2, there is an n,,(k) such that, for each (; I :) = 0 (mod k) and n > n,,(k), there is a universal cycle of (f). In this paper the conjecture
II satisfying
of Chung et al. [2] is verified for k = 3 and partial results
are obtained for k=4, by proving Theorems 2.3, 2.4, 2.6, 2.7 and 3.1. For 4-combinations Theorem 2.6 leaves one set of values, namely, n=2(mod 8), that satisfy the modular condition (“; ‘) = 0 (mod 4), for which no universal cycle of (3 is known to exist. We also have similar results concerning universal cycles of k-combinations with (unlimited) repetition. No universal cycle of the 3-combinations with repetition can exist unless (n, 3)= 1; this leads to Theorem 2.4. No universal cycle of the 4-combinations with repetition of (0,1, . , n- l} can exist unless (n, 4)= 1 or n=6(mod 8); this leads to Theorem 2.7. In a similar way, we denote by [t] the set of all [;I =n(n1) ... (n-k+ 1) kpermutations of the n-set N = (0,1, . . . , n- l}. If there is a cyclic arrangement C=(XlrX2r
permutation
...
where each Xi=09 1, ...) or n- 1, so that C contains each kof [T] as a unique k-block, we say that C is a universal cycle of [;I. This ,y;,),
leads to Theorem 3.1. For the n-set (0, 1, . . . , II- l} there also exist universal cycles of the arbitrary sequences (with unlimited repetition) of length k. This follows from the well-known generalizations of theorems guaranteeing the existence of de Bruijn cycles of order k for any positive
integer
k [l].
2. Universal cycles of k-combinations Let S={i1,i2,..., ik} be a k-combination of (0,1, . . , n- l} written so that i1 6 i2 d ... < ik. In considering these k-combinations, it is often helpful to think of the numbers (0,1, . . . , n - l} as integers modulo n arranged in order around a circle. We say that two k-combinations are of the same type if they differ by just a rotation. The type of a k-combination can also be described by the cycle of differences modulo n between consecutive elements, namely, (i2 - il, i3 - i2, . . . , ik - i,_ 1, il - ik). In constructing universal cycles of a collection of k-combinations, the k-block representing a given k-combination will be determined by the first number and the next k- 1 differences. Thus, for each cycle of n differences chosen to represent a given type of k-combinations, we omit one of the differences and represent it by the sequence of k - 1 differences remaining. When (n, k) = 1, there are always n k-combinations of each
143
Universal cycles of k-subsets and k-permutations
type, one for each starting k-combinations.
number.
Thus, there are (:)/n=(::
:)/k different
types of
2.1. 2-Combinations When Chung
et al. [2] made their conjecture
about
universal
cycles of k-combina-
tions, they knew that it was always possible to construct universal cycles of 2combinations for an n-set as long as IZ- 1~ O(mod 2) or, equivalently, when IZ is odd.
One
might
reason
as follows.
For
any
2-combination
{x, y}, its type
can
be represented by either of the differences x-y or y-x. When n is odd, the possible differences modulo n can be thought of as + 1, - 1, +2, -2, . . , +(n- 1)/2, -(n1)/2. For each 2-combination, we can always represent its type by a positive difference and, in fact, every type of a 2-combination is uniquely represented in the list 1,2, , (n - 1)/2. Every type d represents n 2-combinations, {x, x + d} for every x~(0, 1, . . , n- l}. These 2-combinations can be drawn on a directed graph with vertices 0, 1, . , n- 1. Any 2-combination {x, x+d} is represented by a directed edge from x to x +d. We refer to this digraph as the transition digraph of (T). See Fig. 1 for n = 5. We say that a digraph is balanced if, for every vertex in the digraph, its indegree is equal to its outdegree. The graph in Fig. 1 is balanced since every vertex has indegree two and outdegree two. A digraph is eulerian if it has a circuit which traverses each directed edge exactly once. In this case we note that an eulerian circuit represents a universal cycle of (:) since every 2-combination is represented by a unique edge of the graph and consecutive 2-combinations have an element (vertex) in common. A digraph that is strongly connected and balanced is eulerian. This digraph is clearly strongly connected since any two vertices x and x + m are joined by the directed path x,x+ 1, x +2, . . . ,x +m. Since there is always an eulerian transition digraph of (y) for any odd n, then there is also a universal cycle of (T) for these values of II (Fig. 2).
Fig. 1. A transition
digraph
for (T), N =5.
144
B. W. Jackson
2
3
1
4
3
2
0
0 1
Fig. 2. A universal
4 cycle of(t),
N = 5.
2.2. -l-Combinations Next we consider
3-combinations
of (0,1, . . . , n- l} when (n, 3)= 1. In this case the
cycle of differences modulo n determined by a 3-combination will either consist of three unequal differences or two equal differences and a third number different from these two (but not three equal differences since (n, 3)= 1). In the first instance, we omit any of the three differences, usually the largest, and, in the second instance, we always omit the unequal difference to obtain the sequence representing that type of 3-subset. For n = 8, there are seven types of 3-combinations. The possible cyclic differences modulo 8 are (1, 1, 6), (2, 2,4), (3, 3, 2), (1, 2, 5), (2, 1, 5), (1, 3, 4) and (3, 1, 4), which we represent as types 11,22,33,12,21,13 and 31, respectively. In traversing a circular arrangement of k-combinations, note that a k-block xk) can only be followed by a k-block (x2, x3, . . . , xk + 1). If the differences (x1,x2,..., between consecutive elements in the initial k-block are did* ... dk- 1 then the differences between consecutive elements in the following k-block are d2 d3 ... dk. Thus, it will be helpful to associate a transition digraph with a given representation of types of k-combinations so that type d,dz ... dk_ 1 is represented by a directed edge starting at vertex d,dz ... dk _ 2 and ending at vertex d2 d3 ... dk_ 1. For k = 3 and n = 8, we obtain the transition digraph of Fig. 3, with vertices 1,2,3 and 7 directed edges, one for each of the 7 types of 3-combinations listed above. Note that the digraph in Fig. 3 is balanced and strongly connected; so, it has a circuit which contains each directed edge (type of 3-combination) exactly once. The edges of this eulerian circuit define a circular arrangement which contains each type of 3-combination uniquely, as a 2-block. In this circular arrangement, the sum of the
Fig. 3. A transition
digraph
for types of 3-combinations
with n = 8
Universal
cycles of k-subsets
145
and k-permuiations
differences is relatively prime to 8. Thus, a circular arrangement which contains each 3-combination uniquely as a 3-block can be obtained by starting with a given initial value and successively adding starting point (see Fig. 4). In general, however, universal cycles of(t).
these
we have
differences
a slightly
(8 times)
different
Lemma 2.1. For (n, 3)= 1, there is always
a representation
.for which
is balanced.
the associated
transition
digraph
before
technique
returning
to the
for constructing
of types of 3-combinations
Proof. When (n, 3)= 1, it is always possible to choose representations for types of 3-combinations so that every type is of the form ii or one of a pair of types ij and ji, i #j. A 3-combination of type ii is represented by a directed loop (a l-cycle) from vertex i to itself and 3-combinations of type ij and ji are represented by a pair of oppositely oriented edges between vertices i and j (a 2-cycle). For any directed cycle, the indegree of a vertex is equal to the outdegree and, since the edges of the associated transition digraph can be partitioned into directed cycles, it follows that the transition digraph for this representation of 3-combinations is balanced. 0 Lemma
2.2. For
3-combinations
for
(n, 3)= 1 and which
n 3 8, there
the associated
is always
transition
a representation
digraph
for
types
of
is eulerian.
Proof. Consider the following cases. Case 1: n even. When the cycle of differences modulo n determined by a 3-combination contains two unequal differences, we represent it as type ii for some i = 1,2, . . . , n/2 - 1. When the cycle of differences determined by a 3-combination contains three unequal differences, we omit the largest one to obtain a representation of the form ij, where i, j < n/2 - 1. Note that the type ji will also be chosen for this representation; thus, as in Lemma 2.2, the resulting transition digraph will automatically be balanced. The transition digraph for this set of choices has vertices 1,2, . . . , n/2- 1. There will be
0124672567134723460147 5 2 1 7 5 4 3054207630753216320654 Fig. 4. A universal
cycle of ($, N = 8.
0 1 3 5 6 1
146
B. W. Jackson
a pair of oppositely oriented edges between vertex i=2 >3>..., n/2- 1. Thus, the resulting digraph is strongly eulerian.
1 and connected
vertex and,
i, for hence,
Case 2: n odd. When the cycle of differences modulo n determined by a 3-combination contains two equal differences, we represent it as type ii, for some i = 1,2, . . . , (n - 1)/2. When the cycle of differences for a 3-combination largest difference when it is not equal
contains 3 unequal differences, we omit the to (n- 1)/2; otherwise, we omit the second-
largest
difference. The transition digraph for this representation has vertices balanced. There will be a pair of 12 > ,‘..> (n- 1)/2 and, as before, it is automatically oppositely directed edges between vertex 1 and vertex i, for i = 2,3, . . . , (n - 1)/2 - 1 and also between vertex 2 and vertex (n - 1)/2. Since every vertex is connected by a directed path to vertex 1 and vice versa, the resulting digraph is strongly connected and, thus, eulerian. 0 Using
these facts, we now prove the following
theorem.
Theorem 2.3. Zf (“; ‘) E 0 (mod 3), i.e. for (n, 3) = 1 and n 3 8, there is a uniuersal cycle of (3. Proof. As in Lemma 2.2, it is possible to represent types of 3-combinations so that an eulerian transition digraph is obtained. We now define an expanded transition digraph which contains one edge for each 3-combination of { 1,2, . . . , n}. A 3-combination will be represented by an ordered pair. The first coordinate will be the starting number and the second coordinate the sequence of two differences representing the type of 3-combination. Thus, (x, d,d2) represents the 3-combination {x,x+dl, x+d2}. In a universal cycle of (T), the 3-combination (x, dl d2) will be followed by some 3-combination of the form (x +d,, d2d3). Thus, we define the expanded transition digraph with vertices (x, d) so that there will be a directed edge for each 3-combination (x,dldZ) of (‘;‘) which starts at vertex (x,d,) and ends at vertex (x+dl,d2). The indegree (outdegree) of any vertex (x,d) in the expanded transition digraph will be equal to the indegree (outdegree) of the corresponding vertex d in the original transition digraph. Since the original transition digraph was balanced, it follows that the expanded transition digraph is also balanced. Since the original transition digraph was strongly connected, it had a directed path from vertex d to vertex 1 for every vertex d (and vice versa). For a given x, the directed path in the original transition digraph from d to 1 lifts to a directed path from (x, d) to (y, 1) for some y. The original transition digraph also contains a loop representing 3-combinations of type 11; so, the expanded transition digraph contains an edge from (x, 1) to (x + 1,1) for each x. Thus, there is a directed path in the expanded transition digraph from (y, 1) to (1,1) for each y and, thus, any vertex (x,d) in the expanded transition digraph is connected by a directed path to vertex (1,l) (and vice versa). Therefore, the expanded transition digraph is strongly connected and, thus, eulerian.
147
Universal cycles of k-subsets and k-permutations
The expanded transition digraph is defined so that an edge representing a 3-block (x1, x2, x3) will be followed by an edge representing a 3-block (x2, x3, x4). An eulerian circuit of the expanded transition digraph contains each edge precisely once and, thus, corresponds to a circular arrangement containing each 3-combination of (O,l, . . . , n - l} precisely once as a 3-block. Thus, the resulting of (;). q We obtain a similar
the results
for universal
cycle is a universal
cycles of 3-combinations
cycle
with repetition
in
manner.
In order to construct a universal cycle of the 3-combinations with repetition of an n-set (0,1, . . . , n - l}, it is necessary that the occurrences of a fixed i in with repetition (counting multiplicity) is divisible {O,l, . . . , n - l> in all 3-combinations by 3. Since i occurs once in ($) 3-combinations, twice in n- 1 3-combinations, and thrice in one 3-combination, the total number of occurrences of i is (;) + 2(n - 1) + 3 = (n + 4) (n - 1)/2 + 3, which is divisible by 3 if and only if (n, 3) = 1. We also have the following theorem. Theorem 2.4. with unlimited
If(n, 3) = 1 and repetition
n 3 5 then there is a universal
cycle of the 3-combinations
of (0, 1, . . . , n - 1).
Proof. If a 3-combination with repetition of (0,1, . . , n - l} consists of 3 (not necessarily distinct) elements c1,c2,c3, with c1 dca,
Fig. 5. A transition
digraph
for 3-combinations
with repetition
B. W. Jackson
148
with a representation for types of 3-combinations of IZ+ 3 and subtracting each difference. Thus, the result follows from Theorem 2.3. 0
one from
2.3. I-Combinations In a similar way, we can construct universal cycles of (!) when (n, 4) = 1. In this case the cycle of differences modulo n determined by a 4-combination will either consist of four unequal
differences,
or three equal differences and a fourth number
different from
these or two equal differences and two other numbers different from the first pair and from each other (since n is odd, these are the only possibilities). We always omit the largest difference that is unequal to any of the other three to determine the sequence of differences representing the types of 4-combinations. The resulting types of 4-combi. . .. . nations are either of the form iii, or one of a set of three types, ~11,yl, JU, where i #j, or one of a set of six types ijk, ikj, jik, jki, kij, kji, where i,j and k are three distinct differences. For k=4 and n=9, we have ($/4= 14 types of 4-combinations. They are 111,222,112,121,211,113,131,311,221,212,122,331,313,133. As before, we define the transition digraph for a given representation of types of 4-combinations. The vertices are of the form dldz and each type of 4-combination dldZd3 is represented by a single directed edge from vertex did2 to vertex d2d3. For n = 9, the transition digraph for the types of 4-combinations listed above, is shown in Fig. 6. Lemma 2.5. For (n,4)= 1 and n39, there is always a representation 4-combinations for which the associated transition digraph is eulerian.
of types of
of type iii is represented by a directed loop from vertex ii to . .. . . itself in the transition digraph. A set of three types zy, 91,JZZ IS represented by a directed 3-cycle containing the vertices ii, ij and ji. A set of six types ijk, ikj, jik, jki, kij, kji is represented by two directed 3-cycles containing the vertices ij, jk, ki and ji, ik, kj, respectively. Thus, the resulting transition digraph is balanced. The transition digraph is also strongly connected. Any vertex of the transition digraph is labeled with an ordered pair ij, where i, j < (n - 3)/2. Since vertex ij is joined Proof. A 4-combination
to vertex jl, which is joined transition digraph is strongly
Fig. 6. A transition
to vertex connected
digraph
11 by a directed path and vice versa, the El and, thus, eulerian.
for types of 4-combinations
with n=9.
Universal cycles of k-subsets
und k-permutations
The existence of an eulerian transition digraph be used to construct universal cycles of (2) Theorem 2.6. For (n, 4)= 1 and n>9,
for types of 4-combinations
149
can also
there are universal cycles of(z).
Proof. As before, we define the expanded transition digraph with one directed edge for each 4-combination in (T). The vertices are of the form (x,dId2) and, for each 4-combination (x,dId2d3), there is a directed edge from vertex (x,dId2) to vertex (x+d, ,d2d3). The fact that the expanded transition digraph is eulerian follows from the fact that the original transition digraph is eulerian. Any eulerian circuit of the expanded transition digraph corresponds to a universal cycle of (T); thus, the result follows from Lemma 2.5. 0 The modular condition for 4-combinations states that unless (“; ‘)=O (mod4) no universal cycle of (y) can exist. The only remaining values that satisfy the modular condition but are not covered by Theorem 2.6 are n = 2 (mod 8). When n and k are not relatively prime, one difficulty is that, for certain k-combinations, there are fewer than n combinations of that type and it is not easy to obtain a transition digraph with one edge for each k-combination that is eulerian. As far as the author knows, this remaining case for 4-combinations and the problem for 5-combinations are both still unresolved. However, Hurlbert [3] has shown that, for II 3 18 and (n, 6) = 1, there is a universal cycle of ($). For n 3 7, the conjecture of Chung et al. [Z] remains completely unresolved. Similar results are possible for 4-combinations with (unlimited) repetition. In order to construct a universal cycle of the 4-combinations with repetition of an n-set N = (0,1, . . , n - l}, it is necessary that the occurrences of a fixed i in (0,1, . . . , n- 1) in all 4-combinations with repetition (counting multiplicity) is divisible by four. Since i occurs once in (“: ‘) combinations, twice in (“2)combinations, thrice in n - 1 combinations and four times in one combination, the total number of occurrences of i is (“l I) + 2 (I) + 3(n - 1) + 4, which is divisible by 4 if and only if (n, 4) = 1 or n E 6 (mod 8). We have the following partial result for 4-combinations with repetition. Theorem 2.7. Zf (n, 4) = 1 and n > 5 then there is a universal cycle of the 4-combinations with unlimited repetition of (0, 1, . . , n- l}. Proof. As in the proof of Theorem 2.4, we allow 0 as a difference in describing the type of a 4-combination with unlimited repetition. A representation for types of 4-combinations with repetition of n can be obtained by starting with a representation for types of 4-combinations of n + 4 and subtracting one from each difference; thus, the result follows from Theorem 2.6. 0
3. Universal
cycles of k-permutations
Let ili2...ik be a k-permutation of N= (O,l, . . . ,n- l}, where n>k+ 1. In this case it is just as easy to define a transition digraph with one edge for each k-permutation
150
B. W. Jackson
directly, without referring to classifications of k-permutations into types. Also note that there is no modular condition for universal cycles of k-permutations. In traversing a universal cycle of [T], a k-permutation iliZ ...ik can be followed only by a k-permutation of the form i2i3 ... ikik+ 1. Thus, we define a transition digraph for k-permutations with one vertex for every (k - 1)-permutation of (0,1, . . . , n - l} so that each k-permutation iliZ ...ik is represented by a directed edge starting at vertex lll2 ‘.. ik _ 1 and ending at vertex izi3 . ..i.. We now prove the following theorem. Theorem 3.1. For every k>3 k-permutations [:I.
and n>, k+ 1, there is a universal cycle of the set of
Proof. Every (k- 1)-permutation ili2 ... ik_ I can be extended to a k-permutation by adding any of the n-k + 1 elements in the complement of {il, i2, . , ik _ 1} (to either end). Thus, every vertex ili2 ...ik- 1 in the expanded transition digraph has indegree n-k + 1 and outdegree n-k + 1; so, it is balanced. For every yt> k + 1, the expanded transition digraph is also strongly connected. Let transition digraph for k-permutations. First we 1112 ... ik_ 1 be any vertex of the expanded show that ili2...ik-l is connected to some vertexj,j2...jk_i, withj,
References [l] A. Bondy and G. Murty, Graph Theory with Applications (North-Holland, New York, 1976). [2] F. Chung, P. Diaconis and R. Graham, Universal cycles for combinatorial structures, in: Proc. Southeastern Conf. on Combinatorics, Graph Theory, and Computing, to appear. [3] G. Hurlbert, Ph.D. Thesis, Rutgers University, 1990.
1989