An explicit universal cycle for the (n-1)-permutations of an n-set
We show how to construct an explicit Hamilton cycle in the directed Cayley graph Cay({\sigma_n, sigma_{n-1}} : \mathbb{S}_n), where \sigma_k = (1 2 >... k). The existence of such cycles was shown by Jackson (Discrete Mathematics, 149 (1996) 123-129) …
Authors: ** *Aaron Williams* 및 *Frank Ruskey* (※ 실제 논문 저자는 해당 두 명이거나, 비슷한 연구팀일 가능성이 높습니다.) **
AN EXPLICIT UNIV ERSAL CYCLE FOR THE ( n − 1) -PERMUT A TIONS OF AN n -SET FRANK R USKEY AND AAR ON WILLIAMS Abstract. W e show ho w to cons tr uct an explicit Hamilton cycle in the directed Cayley graph − − → Cay( { σ n , σ n − 1 } : S n ), where σ k = (1 2 · · · k ). The existence of such cyc le s was shown b y Jackson (Discrete Mathematics, 149 (1996) 123–1 29) but the pr o of o nly shows that a certain dire cted gr aph is E ulerian, and Kn uth (V olume 4 F as cicle 2, Generating All T uples a nd Permut ations (2005)) a sks for an explicit co nstruction. W e show that a simple recursion descr ibes our Hamilton cycle and that the cycle can b e genera ted b y an iterative algorithm that uses O ( n ) space. Moreov er, the algo rithm pro duces ea ch successiv e edge of the cycle in constant time; suc h algorithms are said to be lo ople ss . 1. Intro duction and motiv a tion There are many pro ofs in the mat hematical literature sho wing the existence of Hamilton cycles or Eulerian cy cles in imp ortant families o f graphs. How ev er, turning these proo fs in to efficien t algorithms often represen ts a significan t c hallenge. An in teresting case in p oin t is the w ell-kno wn De Bruijn cycle, whic h is a length k n circular string o ve r a k -ary alphab et with the prop ert y that ev ery length n string o ccurs a s a sub- string. The existence of De Bruijn cycles is commonly presen ted in undergraduate discrete mathematics courses as a consequence o f a certain gra ph b eing Eulerian. Ho wev er, it is not widely kno wn ho w to efficien tly generate a De Bruijn cycle. In the authors’ view t w o aspects of this question hav e pa rticular imp ortance. • Space, not t ime, is the primary enemy . A na ¨ ıv e solution w ould b e to build the graph and then use a Eulerian cycle algorithm to pro duce the cycle. This will be practical for small v alues of n and k , but fo r large v alues space will b e the limiting factor long b efore t ime b ecomes a fa ctor. In g eneral, w e need to b e able to generate the Hamilton or Eulerian cycle without building the graph, or storing ex p onen tia lly- long sublists. There a r e algorithms for building De Bruijn cycles that use space O ( n ). The earliest of these is due to F redric ksen and Maiora na [3] and is presen ted in Knu th [8]. • The develop men t of efficien t algorithms rev eals st ructure. It is often w orth- while to turn a pro of into an algorithm, or to dev elop an alternate pro of, b ecause the Research supp o rted in part by NSER C. 1 2 F. RUSKEY AND A . WILLIAMS pro cess often results in a deep er structural understanding of the cycles being listed. F or example , the effi cien t algorithm due to F redric ksen and Maiorana is based on nec klaces, Lyndon w ords, and is related to pattern-matc hing and Lyndon factoriza- tion. As another example fr o m the Hamiltom cycle domain, Eades, Hic k ey , a nd McKa y [2] con- sidered the g raph G ( n, k ) whose v ertices are all length n bitstrings with density k and where t wo bitstrings are j o ined b y an edge if they differ b y transp o sing tw o adjacen t bits. They sho we d that G ( n, k ) is Hamiltonian if and only if n is ev en and k is o dd. The pro of is inductiv e and relies on the fact that the graph has a spanning subgraph tha t is the prism of t w o “ combs.” Ho w ev er, it was not at all clear ho w to turn that pro of in to an efficien t algorithm. Ev en tually an algorithm that mimics the pro of w as found that uses O ( n ) space and take time O (1) p er bitstring generated [5]. In the presen t pap er w e are considering the construction of a “ univ ersal cycle ” for the ( n − 1)-p erm utatio ns of an n -set ( which w e tak e to b e { 1 , 2 , . . . , n } ). Here a universal cycle is a circular string of length n ! what con tains eac h o f the n ! differen t ( n − 1)-p erm utations as a (con tiguous) substring. F or example, 321312 is a suc h a univers al cycle for n = 3, since its substrings are 3 2, 21, 1 3 , 31, 12, and 2 3. More general univ ersal cycles were in tr o duced by Ch ung, Diaconis, and Gra ham [1] as a w a y of extending the de Bruijn cycle idea to com binatorial ob jects in general. The exis tence of a univ ersal cycle for the k -p erm utations of an n -set w a s sho wn by Jac kson [6] when k < n . His pro of sets up a certain natural Eulerian graph, call it J k ,n , and shows that an y Eulerian cycle in that graph corresp onds to the required univ ersal cycle. Ho w ev er, no explicit construction of the cycle is indicated. The problem for k = n − 1 is discussed b y Kn uth [8] in Exercise 112 of Section 7.2.1.2 . On page 12 1 of [8] w e find the follo wing quote: “A t least one of these cycles m ust a lmost surely b e easy to describ e and to compute, a s w e did for de Bruijn cycles in Section 7.2.1.1. But no simple construction has y et b een found.” The purp ose of this paper is to pro vide suc h a description and computational metho d. W e will sho w how to construct a particular univ ersal cycle. Our algo rithm tak es space O ( n ) and uses a constan t amoun t of time b et wee n success iv e outputs of characters in the cycle. T o b e precise regrading the space requirem en t: The alg o rithm use s a constan t num b er o f arrays , eac h with O ( n ) indice s, and eac h storing in tegers o f v alue at most n . Similarly regarding time, we us e a cons tan t n um b er of op erations (comparisons, incremen ts, decremen ts, a nd parit y tests) on in tegers of v alue at most n . Univ ersal cycles f o r t he p ermutations of an n -set are not directly p ossible unless n ≤ 2. Ho wev er, eve ry ( n − 1)- p erm utation of a n n -set can b e uniquely extended to a p erm utatio n of an n -set b y app ending the unique missing sym b ol. T h us, univ ersal cycles for ( n − 1 )- p erm uta tions can b e view ed as univ ersal cycles for p ermutations. F or example, 3 2 1312 AN EXPLICIT UNIVERSAL CYCLE FOR THE ( n − 1)-PERMUT A TIO NS OF AN n -SET 3 pro duces the p erm utations 321 , 213, 132, 312, 123, a nd 231, where the app ended missing sym b ols are underlined. F or this reason, our res ults add to the already siz eable lit era t ure on generating p erm utatio ns. A go o d surv ey is provided by Sedgewic k [11] and more recen t dev elopmen ts are to b e found in Knuth [8]. W e don’t ex p ect our algorithms to b e a fast w a y to generate p ermutations using the usual mo del of computatio n, sinc e at least n − 1 of the n v alues c hange at eac h step. How ever, they will b e fast if a circular represen tation is used; for ex ample, when using link ed lists or a circular array . In a circular array w e main tain a start p osition a nd do arithmetic on indices mo d n . They will also b e fa st if the p erm utation is stored as a computer w ord. F or example, w e can store the p ermutations up to n = 16 by dividing 64 bit w ords into 4 half-b ytes. The shifts can then b e accommo dated in a few ma chine instructions. Finally , w e men tion that additional sym b ols can also b e used to create univ ersal cycle s whose substrings are or der isomorphic t o permutations. F or example, 421423 pro duces the p erm uta tions 321, 213, 132, 312, 123, and 231. Recen tly Johnson [7] prov ed a conjecture in [1] by sho wing tha t n + 1 sy m b o ls are alwa ys sufficien t for constructing these univ ersal cycles. The pap er is organized as follo ws. In Section 2 w e giv e our explicit construction as a certain recursiv ely defined string. Then, in Section 3, we sho w that this string can b e generated b y an algorithm that uses only a constan t amoun t of computatio n betw een the o utput of success iv e sym b ols of the string — the fir st suc h alg o rithm fo r a univ ersal cycle. In Section 4, we giv e further prop erties of our recursiv e construction; first some results on the num b er of σ n or σ n − 1 op erations that are used, then that our ordering has an efficien tly computable ranking function, and finally that it is “mu ltiv ersal,” in a sense to b e describ ed later. W e conclude with Section 5, whic h contains some op en problems. 2. An explicit construction Initially , w e will couc h our discussion in terms of finding Hamilton paths in certain di- rected Ca yley graphs. Ca yley graphs are denoted X = − − → Ca y ( { α 1 , α 2 , · · · , α k } : G ). Here { α 1 , α 2 , · · · , α k } is a generating set of a group G . T he v ertices of X are the elemen ts of G and the edges are all of the fo r m g → α i g ; these edges are usually though t of as b eing lab elled with α i . In an undir e cte d Cay ley graph, if α is in the generating set, then its in v erse α − is also in the generating set. Driv en by the question of Lov ´ asz of whether there is a Hamilton cycle in all undir e cte d Ca yley graphs, there is a significan t lit era t ur e of results ab out Hamilton cycle s in Ca yley graphs. A surv ey may b e fo und in G allian and Witte [4]; see also P ak and Ra do ˇ s Ra doi ˇ ci ´ c [10]. In the solution to Exercise 112 of Section 7.2.1.2 Don Knuth implicitly po ses the problem of finding an explicit expression for univers al cycles of ( n − 1) - p erm utations of an n -set [8]. This problem is equiv alen t to generating p erm utations of an n - set b y rotations of the form 4 F. RUSKEY AND A . WILLIAMS (1 2 · · · n ) or (1 2 · · · n − 1); i.e., it is equiv a len t to asking whether the Ca yley graph Ξ n := − − → Ca y ( { σ n , σ n − 1 } : S n ) is Hamiltonian. W e use S k ,n to denote the set of k -p ermutations of the n -set [ n ] = { 1 , 2 , . . . , n } . In the case where k = n w e use S n . Althoug h w e do not use this fact b elow , it is in teresting to note that a short pro of r ev eals that the graph Ξ n is the line gr a ph of the Jack son gr a ph J n − 1 ,n . Consider the binary string S n defined b y the following recursiv e rules. The base case is S 2 = 00. Let S n = x 1 x 2 · · · x n ! where x denotes flipping the bit x . Then, for n > 2, (1) S n +1 := 001 n − 2 x 1 001 n − 2 x 2 · · · 001 n − 2 x n ! . W e use ab o v e the usual con ven tion that if w is a string and m is an in teger then w m is w concatenated t ogether m times, w m = w w · · · w ; also w 0 is the empt y string. Belo w w e list S 3 , S 4 , and S 5 . Eac h S i is of the for m w w since 00 ha s this property and the recurrence (1) preserv es it. S 3 = 00 ¯ 0 00 ¯ 0 = 00 1 00 1 . S 4 = 001 ¯ 0 001 ¯ 0 001 ¯ 1 001 ¯ 0 001 ¯ 0 001 ¯ 1 = 001 1 001 1 001 0 001 1 001 1 001 0 . S 5 = ( 0011 1 0011 1 0011 0 0011 0 0011 1 0011 1 0011 0 0011 0 00 11 1 0 0 11 1 0 011 0 0011 1 ) 2 No w define the mapping φ b y 0 → σ n and 1 → σ n − 1 where σ k = (1 2 · · · k ). Theorem 2.1. The list φ ( S n ) is a Hamilton cycle in the dir e cte d Cayley gr aph Ξ n . Pr o o f. In listing the Ha milto n cycle w e use one-line notatio n for the p erm uta t ions, starting with n n − 1 · · · 2 1, and think of the cycles σ n − 1 and σ n as a cting o n the p ositions in t he one-line nota t io n. Thus , in a sligh t abuse of nota tion, φ ( S 3 ) = 321 , 213 , 132 , 312 , 123 , 231 , since S 3 implies the succ essiv e application of σ 3 , σ 3 , σ 2 , σ 3 , σ 3 , and finally σ 2 to map the last p erm utation to t he first. Our pro of strategy is t o giv e an explicit listing of p erm uta tions of [ n ] with the required prop erties and then show that it is equiv alen t to (1). Recursiv ely define a cir cular list Π( n ) = Π( n ) 0 , Π( n ) 1 , . . . , Π( n ) n ! − 1 of p ermutations of [ n ]. F or small v a lues of n , defin e Π(1) = 1, Π(2) = 21 , 12, and Π(3) = φ ( S 3 ). Ev ery n -th p erm utation of Π( n ) is defined as follo ws. (2) Π( n ) j n := n Π( n − 1) j . AN EXPLICIT UNIVERSAL CYCLE FOR THE ( n − 1)-PERMUT A TIO NS OF AN n -SET 5 The n − 1 p erm utatio ns that follow nπ , where π = Π( n − 1) j , are defined to b e (3) σ n ( nπ ) , σ 2 n ( nπ ) , σ n − 1 ( σ 2 n ( nπ )) , . . . , σ n − 3 n − 1 ( σ 2 n ( nπ )) . The list Π(4 ) is sho wn in T able 1, column ( d). The p ermutation nπ follow ed by the p ermu ta- tions ab ov e comprise the sublist Π( n ) j n , Π( n ) j n +1 , . . . , Π( n ) ( j +1) n − 1 and these permutations are all distinct since the p osition of n is successiv ely in the n differen t p ositions 1, n , n − 1, . . . , 2. F urthermore, b ecause w e can recov er π from an y permutation in this sublist, the uniqueness of ev ery p erm utation in Π( n ) follo ws inductiv ely from the uniqueness of ev ery p erm uta tion in Π( n − 1). It remains only to pro v e that successiv e p ermutations differ b y σ n or σ n − 1 and that the list is circular. It is clear fro m (3) that succes siv e p ermu tations differ b y σ n or σ n − 1 , except for those that precede the one of the form nπ success iv ely follow ed b y nπ . Let aτ z b e a p erm uta tion of 1 , 2 , . . . , n − 1 where a and z are nu m b ers and τ is a sequence (of length n − 3). Note t ha t the last p erm utation of (3) is σ n − 3 n − 1 ( σ 2 n ( naτ z )) = σ − 2 n − 1 ( σ 2 n ( naτ z )) = σ − 2 n − 1 ( τ z na ) = z nτ a. No w supp ose that π = Π( n − 1) j = aτ z and π ′ = Π( n − 1) j +1 . Inductiv ely , either π ′ = σ n − 1 ( π ) or π ′ = σ n − 2 ( π ). Observ e that σ n ( z nτ a ) = nτ az = nσ n − 2 ( aτ z ) , and (4) σ n − 1 ( z nτ a ) = nτ z a = nσ n − 1 ( aτ z ) . (5) Since the successor of aτ z is either σ n − 2 ( aτ z ) or σ n − 1 ( aτ z ), the transition to the p erm utatio n π ′ is also of the correct form; successiv e p ermutations in Π( n ) differ b y σ n or σ n − 1 . The circularit y of the list f o llo ws inductiv ely fro m the circularit y of the list Π( n − 1 ) (alternativ ely w e could use Lemma 2.2 below). F urthermore, in terms of the mapping φ defined earlier, the bits are flipp ed; a 0 ( σ n − 1 ) transition in Π( n − 1) b ecomes a 1 ( σ n − 1 ) transition in Π( n ) b y (5), and a 1 ( σ n − 2 ) transition in Π( n − 1) b ecomes a 0 ( σ n ) transition in Π( n ) by ( 4). Lemma 2.2. Any Hamil ton p ath in Ξ n is, in fa ct, a Hamilton cycle. Pr o o f. Supp ose that Π = Π 1 , Π 2 , . . . , Π n ! is a Hamilton path in Ξ n that is not a Hamilton cycle. In particular σ n (Π n ! ) 6 = Π 1 and σ n − 1 (Π n ! ) 6 = Π 1 . Th us Π n ! 6 = σ − n (Π 1 ) a nd Π n ! 6 = σ − n − 1 (Π 1 ). W e m ust then hav e that σ − n (Π 1 ) → σ n − 1 ( σ − n (Π 1 )) and σ − n − 1 (Π 1 ) → σ n ( σ − n − 1 (Π 1 )) are distinct edges in Π( n ). Ho w ev er, an easy calculation sho ws that σ − n − 1 σ n = σ − n σ n − 1 = ( n − 1 n ) and th us these permutations are iden tical. This con tradiction sho ws that Π is a Hamilton cycle. The pro of sho ws that in fact the lemma is true fo r an y Ca yley graph o n tw o generator s ρ and τ fo r whic h τ − ρ is an inv olution. The univ ersal cycle for ( n − 1)-p ermutations of [ n ] is obtained b y recording the first sym b ol in each of the p erm utatio ns in Π( n ). W e use U n to denote the resulting univ ersal cycle. 6 F. RUSKEY AND A . WILLIAMS 3. A loopfree algorithm Supp ose that in our recurrence (1) for S n +1 that for each “new” bit w e record t he v alue n , and apply this idea recursiv ely . Call the corresp onding new sequence R n +1 . That is, R 2 = 11, and for n > 1, R n +1 = n n y 1 n n y 2 · · · n n y n ! , where R n = y 1 y 2 · · · y n ! . F or example R 4 = 33 3 2 333 2 333 1 333 2 333 2 3 3 3 1 . The sequence R 4 is exactly the sequenc e that is obtained b y recording the most significan t p osition that ch anges when counting with the m ulti-ra dix n um b ers with para meters 2 × 3 × 4, when the num b ers are indexed 1, 2, 3, fr o m left-to -righ t. See T able 1, columns (a) and (b). In general, R n giv es us the p ositions when coun ting with m ulti-radix n um b ers 2 × 3 × · · · × n . These observ ations suggest that w e may b e able to efficien tly generate t he S n sequence b y mo difying the classic algorithm for coun t ing with m ulti-r a dix n umbers. In the classic algorithm the multi-radix n umber is stored in the arra y a n − 1 · · · a 2 a 1 and j is used to repres en t the righ tmost, or smallest, index where a j is no t at its maxim um v alue. The next m ulti- radix num b er is obtained b y incremen ting a j and setting all v alues to its righ t to 0. Now supp ose that we just incremen ted the in teger in p osition j so t ha t the multi-radix num b er is a n − 1 · · · a j a j − 1 · · · a 1 = a n − 1 · · · a j 0 · · · 0. Then the corresp onding R n v a lue is n − j and so the non-recursiv e part of t he S j sequence that w e ar e listing is going t hr o ugh the pattern 001 n − j − 1 or t he patt ern 110 n − j − 1 , dep ending on whether j is o dd or ev en, resp ectiv ely . F or prop osition P w e use the nota t io n [ [ P ] ] to mean the v alue 1 if P is t r ue and the v alue 0 if P is false; also ⊕ denotes exclusiv e-or. The expression [ [ j ev en ⊕ a j ≤ 1] ] giv es the correct v a lue of the bit to b e output. Belo w is the en tire algorithm, rendered in pseudo-co de. a n +1 a n · · · a 1 ← 0 0 · · · 0; rep eat j ← 1 ; while a j = n − j do a j ← 0 ; j ← j + 1; o d ; output ( [ [ j ev en ⊕ a j ≤ 1] ] ); a j ← a j + 1; un til j ≥ n ; There is an lo opless alg orithm for listing m ulti- radix num b ers as a Gray co de in whic h the v a lue in only one p osition changes and that change is b y ± 1 (see, for example, Williamson [12], pg. 112, o r Knuth [8], pg. 20). T ogether with the ideas used in t he previous “counting” algorithm, w e can adapt t hose lo opless algorithms to get a lo opless algorithm for generating S n or our univ ersal cycle. In the G ra y co de for multi-radix num b ers, the v alues in a given p osition alternately increase and decrease. F urthermore, the v alues c hange in exactly the AN EXPLICIT UNIVERSAL CYCLE FOR THE ( n − 1)-PERMUT A TIO NS OF AN n -SET 7 (a) (b) (c) (d) (e) (f ) (g) 234 R 4 234 S 4 S 4 U 4 rank 000 3 000 . . 0 4321 4 0 001 3 001 . . 0 3214 3 1 002 3 002 . . 1 2143 2 2 003 2 003 . 1 . 1423 1 3 010 3 013 . . 0 4213 4 4 011 3 012 . . 0 2134 2 5 012 3 011 . . 1 1342 1 6 013 2 010 . 1 . 3412 3 7 020 3 020 . . 0 4132 4 8 021 3 021 . . 0 1324 1 9 022 3 022 . . 1 3241 3 10 023 1 023 0 . . 2431 2 11 100 3 123 . . 0 4312 4 12 101 3 122 . . 0 3124 3 13 102 3 121 . . 1 1243 1 14 103 2 120 . 1 . 2413 2 15 110 3 110 . . 0 4123 4 16 111 3 111 . . 0 1234 1 17 112 3 112 . . 1 2341 2 18 113 2 113 . 1 . 3421 3 19 120 3 103 . . 0 4231 4 20 121 3 102 . . 0 2314 2 21 122 3 101 . . 1 3142 3 22 123 1 100 0 . . 1432 1 23 T able 1. (a) Counting in multi-radix base 2 × 3 × 4, ( b) the R 4 sequence , (c) the corresponding m ulti-radix Gray code, (d) indente d ve rsion of S 4 , (e) the list Π(4), (f ) the univ ersal cycle U 4 , and (g) the rank of eac h p ermutation. p ositions given b y the R n sequence . In the implemen tation w e main tain a direction array d where +1 means increase and − 1 means decrease W e a lso maintain an arra y f o f “fo cus p oin ters” whic h allo w instant acce ss to the next po sition whose v alue will change (w e set f n = n +1 (instead of n ) so that the last iteration is handled correctly). See T able 1, column (c), for an example. Th us the v alues of j f r o m the coun ting alg o rithm are exactly the same in the Gra y co de algorithm, except that in the Gr ay co de algorithm j is the p osition where a v alue c hanges. The only complication arises b ecause the v alues in a giv en p o sition can b e dec reasing, and so the test “ a j ≤ 1” is not sufficien t. F ortunately , all algorit hms that lo oplessly implemen t the Gray code ma intain an arra y of directions d n − 1 · · · d 2 d 1 for eac h p osition, where d i ∈ 8 F. RUSKEY AND A . WILLIAMS { +1 , − 1 } , indicating whether the v alues in that p osition ar e curren tly increasing (+1) or decreasing ( − 1). If d j = +1 then w e can con tin ue to test a j ≤ 1, but to account for d j = − 1, w e need to test ( a j ≤ 1 and d j = 1) or ( a j ≥ n − j − 1 and d j = − 1) . W e can “ optimize” this condition. Notice that the test ( a j ≤ 1 and d j = 1) can b e replaced b y a j − d j ≤ 0. This c hange is p ossible b ecause if d j = − 1 then a j − d j is guaran teed to b e greater than zero b ecause a j ≥ 0. Therefore, if a j − d j ≤ 0, then this immediately implies that d j = 1 and so a j − 1 ≤ 0 , whic h is equiv alent to the original test a j ≤ 1. Lik ewise, the test ( a j ≥ n − j − 1 and d j = − 1) can b e replaced by a j − d j ≥ n − j . Below is our loo pless algorithm in full detail. a n +1 a n · · · a 1 ← 0 0 0 · · · 0; d n d n − 1 · · · d 1 ← 1 1 1 · · · 1; f n f n − 1 · · · f 1 ← n +1 n − 1 n − 2 · · · 1; rep eat j ← f 1 ; f 1 ← 1 ; output ( [ [ j ev en ⊕ ( a j − d j ≤ 0 or a j − d j ≥ n − j ) ] ] ); a j ← a j + d j ; if a j = 0 or a j = n − j then d j ← − d j ; f j ← f j +1 ; f j +1 ← j + 1; fi ; un til j ≥ n ; It is also po ssible to output the univ ersal cycle it self in a lo opless manner, but an additional circular array is required to hold the curren t p ermutation. T o follo w are the details. Define an arra y π 1 π 2 · · · π n initialized to n n − 1 · · · 1 and an index t that will b e incremen ted mo d n on eac h iteration of t he alg o rithm. W e will think of π as a circular arra y . The index t is the p osition of the last elemen t of π , so initially t = n . As eac h bit of S n is determined, w e will ouput the first elemen t of π (i.e., the one in p osition t + 1). If the bit is a 1, so that σ n − 1 is acting on π then w e need t o sw ap the last t wo elemen ts: π t − 1 ↔ π t . In ot her words the output statemen ts in the preceding co de fragments is replaced with the follow ing co de where expr is the expression insid e of the output statemen t in either the previous counting algorithm of the previous lo opless algorithm. t ′ ← t ; t ← ( t + 1) mo d n ; output ( π ( t +1) m od n ); if expr = 1 then π t ↔ π t ′ fi ; Finally , w e note that eve ry p erm uta t ion can be output in a circular fashion b y o utputt ing π and t . W e could also use a link ed list, which w ould g iv e a lo opless permutation generation algorithm. AN EXPLICIT UNIVERSAL CYCLE FOR THE ( n − 1)-PERMUT A TIO NS OF AN n -SET 9 4. Fur ther p ro per ties In this section we explore further prop erties of Ξ n and our Hamilton cycle. 4.1. H ow man y of eac h rotation is used? It is clear from the recurrence relation (1) that the n umber, call it f n , of σ n ’s in φ ( S n ) satisfies the recurrence relation (6) f n +1 = ( 2 if n = 1 3 n ! − f n if n > 1 . This recurrence relation can b e iterated t o obtain f n = 2( − 1) n − 3 n − 1 X k =1 ( − 1) k ( n − k )! , from whic h it follows that f n ∼ 3( n − 1)! or f n n ! ∼ 3 n . In terestingly , this sequen ce app ears in OEIS [9] as A12 2 972( n + 1 ) as the solution to the “symmetric” recurrence relation a ( n + 1 ) = ( n − 1) · a ( n ) + n · a ( n − 1). The v alues of f n for n = 1 .. 1 0 are 1, 2, 4, 14, 58, 3 02, 1858 , 13 2 62, 1076 98, 980942. Consider the cosets induced b y σ n ; there are n ! /n = ( n − 1)! of them. In a Hamilton cycle there m ust be at least one σ n − 1 edge that leav es eac h coset, and th us there m ust b e at least ( n − 1)! of them. Alternativ ely , consid er the cosets induced b y σ n − 1 ; there are n ! / ( n − 1) = n · ( n − 2)! of them. In a Hamilton cycle there m ust b e at least one σ n edge that leav es the coset, and th us there m ust be at least n · ( n − 2)! of them. W e can mak e a stronger statemen t regarding the σ n edges. Lemma 4.1. The le as t n umb er of σ n e dges i n any Hamilton cycle in Ξ n is 2 n ( n − 2)! − 2 . Pr o o f. First, observ e t ha t σ − − 1 σ n σ − n − 1 σ n = ( n − 1 n )( n − 1 n ) = id . The tw o σ n edges a b o v e are inciden t with the same unordered pair of cosets induced by σ n − 1 . Thus if w e con tr act eac h coset in to a singe sup er-v ertex, then the resulting gra ph, call it Q n , is undirected in the sense that ev ery directed edge is pa ir ed with an edge in a 2-cycle. F urthermore, it is not hard to see t hat if one of tho se σ n edges is used in a Hamilton cycle, then so m ust the other. Th us a Hamilton cycle in X n b ecomes a connected spanning subgraph of Q n . Since a minimal connected spanning subgraph is a spanning tree, and any spanning t r ee has n · ( n − 2)! − 1 edges, the num b er of σ n edges is at least 2 n ( n − 2)! − 2. Figure 1 sho ws the Ca yley graph X 4 . Note that the con tracted graph Q 4 is the 3-cube. The red edges sho w the Hamilton cycle S 4 . In this case S n corresp onds to a spanning tree in Q n , but this is not the case for n ≥ 6. 10 F. RUSKEY AND A . WILLIAMS 132 134 123 234 143 142 243 124 Figure 1. The Ca yley graph Ξ 4 on the left. The graph Q 4 on the right. The thic k (red) edges indicate the Hamilto n cycle S 4 . 4.2. R anking. The r ank o f a p ermutation π is the v alue r for whic h Π( n ) r = π . Our recursiv e equation for the rank dep ends o n the p o sition of n within the p ermu tation b eing rank ed. F rom the definition of Π( n ) w e can infer that rank( a 1 a 2 · · · a k − 1 na k +1 · · · a n ) = 0 if n = 1 , n · rank( a 2 a 3 · · · a n ) if k = 1 , n − k + 1 + n · rank( a n a k +1 · · · a n − 1 a 1 · · · a k ) if k > 1 . The expression n − k + 1 accoun ts for the po sition of the n , and the rest comes from the recursiv e part of the definition o f Π( n ). W e can also express the rank as rank( αnβ ) = 0 if α = β = ǫ, n · rank( β ) if α = ǫ, n − | α | + n · rank( σ ( β ) α ) otherwise , where σ ( β ) is β rotated one p osition to t he right. Implemen ted in the ob vious ma nner, these recurrence relations lead to alg o rithms that use O ( n 2 ) arithmetic op erations on intege rs as large as n !. 4.3. Multiversal Cycle Prop erty. In this section we prov e that the sequence Π( n ) = Π( n ) 0 , Π( n ) 1 , . . . , Π( n ) n ! , written out as a long string of sym b ols b y concatenating each p erm uta tion, is a “m ultiv ersal cycle”. W e denote this “flattening” of Π( n ) a s ` ( n ). F or AN EXPLICIT UNIVERSAL CYCLE FOR THE ( n − 1)-PERMUT A TIO NS OF AN n -SET 11 example, consider ` (3) = 32 1 213 132 312 123 23 1. Starting in p ositions 0,1, or 2 and adv a ncing the p osition in incremen ts of 3, recording the first t wo sym b ols, w e obtain 0 32 21 13 3 1 12 23 1 21 13 32 12 23 31 2 12 31 23 21 32 13 In eac h case a complete set of all 2- p erm uta t io ns of [3] is o btained. The purp ose of this section is to prov e that this pro p ert y holds in g eneral. Definition 4.2. A multiversal cy cle for the ( n − 1)-p erm utatio ns of an n -set is a circular string a 0 a 1 · · · a N − 1 of length N = n · n ! suc h that, f or all m = 0 , 1 , . . . , n − 1, (7) { a m + in · · · a m + in + n − 2 | i = 1 , 2 , . . . , n ! } = S n − 1 ,n , where arithmetic in the indices is tak en mo d n . Before getting to t he main theorem in this section w e pro v e a technic al lemma. Lemma 4.3. F or al l i 6 = 0 , − 1 mo d n , if ` ( n ) = a 0 a 1 · · · a N − 1 , then a i = a i + n − 1 . Pr o o f. Because i 6 = 0 mo d n the num b ers a i and a i + n − 1 lie in t w o succes siv e p erm utations of Π( n ). The conclusion no w follows since success iv e p erm utations differ by σ n or σ n − 1 . The i 6 = − 1 mo d n conditio n is necessary when they differ b y σ n − 1 . Theorem 4.4. The string ` ( n ) = a 0 a 1 · · · a n ! − 1 is a multiversa l cycle. Pr o o f. The pro of is b y induction on the v alue m in the definition. The base case m = 0 sat- isfies (7) b ecause Π( n ) 0 , Π( n ) 1 , . . . , Π( n ) n ! − 1 is a listing of all p erm uta tions of [ n ], so ignoring the last c haracter of eac h permutation giv es a complete listing of all ( n − 1)-p ermutations of [ n ]. Similarly , when m = 1, ig noring the first c haracter of eac h p erm uta tion also giv es a complete listing of all ( n − 1)-p ermutations of [ n ]. W e now a rgue b y con tradiction. Supp ose that there are some v alues m > 1, i and i ′ , with i 6 = i ′ , suc h that (8) a m + in · · · a m + in + n − 2 = a m + i ′ n · · · a m + i ′ n + n − 2 . Inductiv ely , w e know that a m − 1+ in · · · a m − 1+ in + n − 2 6 = a m − 1+ i ′ n · · · a m − 1+ i ′ n + n − 2 . Th us it m ust b e the case that a m − 1+ in 6 = a m − 1+ i ′ n . How eve r, applying Lemma 4 .3 to a m − 1+ in and a m − 1+ i ′ n giv es a m − 1+ in = a m − 1+ in + n − 1 and a m − 1+ i ′ n = a m − 1+ i ′ n + n − 1 , 12 F. RUSKEY AND A . WILLIAMS so long as m 6 = 0 , 1. But by (8) we no w ha v e a m − 1+ in = a m − 1+ in + n − 1 = a m + in + n − 2 = a m + i ′ n + n − 2 = a m − 1+ i ′ n + n − 1 = a m − 1+ i ′ n , whic h is a con tr a diction. The careful reader will ha ve noted that Lemma 4.3 a nd Theorem 4.4 apply to any Ha milto n cycle in Ξ n since the only prop erty that w e use is that successiv e p erm utatio ns differ by σ n − 1 or σ n . 5. Final Re marks, Open Problems In this pap er we hav e deve lop ed an explicit algorithm for generating a univ ersal cycle for the ( n − 1)-p erm utatio ns of an n -set. This is t he first univ ersal cycle f o r whic h a lo opless algorithm has b een disco v ered. Belo w is a list o f op en problems inspired by this work. • Can the r esults of this pap er be extende d to k -p erm utations of [ n ] f o r 1 ≤ k < n − 1? • Among all Hamilton cyc les in Ξ n w e determined in Lemma 4.1 the least n um b er of σ n edges that need to b e used in a Hamilton cycle in Ξ n . What is the least num b er of σ n − 1 edges that need b e used? In our construction, the num b er of σ n edges is asymptotic to 3 /n and the n um b er of σ n − 1 edges is asymptotic to ( n − 3) /n . Is there a general construction t ha t uses mor e σ n edges than σ n − 1 edges? • Can the r esults of this pap er be extended to the p ermu tations of a mu ltiset? That is, give n m ultiplicities n 0 , n 1 , . . . , n t , where n i is the n um b er o f times i o ccurs in the m ultiset and n = n 0 + n 1 + · · · + n t , is there a circular string a 1 a 2 · · · a N of length N = N n 0 ,n 1 ,...,n t with the prop erty that { a i a i +1 · · · a i + n − 2 ι ( a i , a i +1 , . . . , a i + n − 2 ) | 1 ≤ i ≤ N } is equal to the set of all p erm utations of the multis et. Since the length of a i a i +1 · · · a i + n − 2 is n − 1 it is not a p ermutation of the multise t; one c haracter is missing. The function ι giv es the missing c haracter. W e call these strings sh orthand universal cycles . The curren t pap er ga v e a shorthand cycle fo r p ermu tations of [ n ]. • It w ould b e interesting to gain more insigh t in to the ranking pro cess. Is there a w ay to iterate the recursion so that it can b e express ed as a sum? Reference s [1] F an Chung, Persi Diaconis, and Ron Graham, Universal cycles for c ombinatorial structure s , Discrete Mathematics, 110 (1992) 43– 5 9. [2] P . Eades, M. Hick ey , and R.C. Read, Some Hamilton p aths and a minimal change algorithm , Journal of the ACM, 31 (1984) 19–29 . [3] H. F redricksen and J. Ma iorana, Ne cklac es of b e ads in k c olors and k -ary de Bruijn se quenc es , Discrete Mathematics, 23 (1978 ) 207-2 10. AN EXPLICIT UNIVERSAL CYCLE FOR THE ( n − 1)-PERMUT A TIO NS OF AN n -SET 13 [4] J. Gallian and D. Witte, A survey: hamiltonian cycles in Cayley gr aphs , Discrete Mathematics, 51 (1984) 2 93–3 04. [5] T. Hough and F. Ruskey , An Efficient Implementation of the Eades, Hickey, R e ad A djac ent Inter- change Combination Gener ation Algorithm , Jo urnal o f Combinatorial Mathema tics and Combinatorial Computing, 4 (19 88) 79–8 6. [6] B. Jackson, Universal cycles of k -subsets and k - p ermutations , Discrete Mathematics, 149 (1996) 123– 129. [7] R. Johnson, Universal cycles for p ermutations , Discrete Mathematics, to app ear . [8] D.E. Knuth, The Art of Computer Pr o gr amming, V olume 4, Gener ating A l l T uples and Permutations , F ascicle 2, Addison-W esley , 20 05. [9] N.J.A. Sloane, The Online Encyclop e dia of Inte ger Se quen c es , http:/ /www. research.att.com/ ~ njas/s equen ces/ . [10] Igor Pak and Rado ˇ s Radoiˇ c i´ c, Hamiltonia n p aths in Cayley Gr aphs , manuscript, 2004. [11] Rob ert Sedgewick, Permutation Gener ation Me tho ds , Computing Surveys, 9 (19 77) 13 7-164 . [12] S. Gill Williamson, Combinatorics for Computer Scienc e , Computer Science Pr e s s, 1 985. Dept. of Computer Science, University of Victoria, CANADA URL : http: //www. cs.uvic.ca/~ruskey Dept. of Computer Science, University of Victoria, CANADA
Original Paper
Loading high-quality paper...
Comments & Academic Discussion
Loading comments...
Leave a Comment