View metadata, citation and similar papers at core.ac.uk brought to you by CORE
provided by Elsevier - Publisher Connector
Theoretical Computer Science 307 (2003) 415–431 www.elsevier.com/locate/tcs
Aloopless algorithm for generating the permutations of a multiset
Vincent Vajnovszki LE2I-CNRS FRE 2309, Universiteà de Bourgogne, B.P. 47 870, Dijon 21078, Cedex, France
Abstract
Many combinatorial structures can be constructed from simpler components. For example, a permutation can be constructed from cycles, or a Motzkin word from a Dyck word and a combination. In this paper we present a constructor for combinatorial structures, called shu)e on trajectories (deÿned previously in a non-combinatorial context), and we show how this constructor enables us to obtain a new loopless generating algorithm for multiset permutations from similar results for simpler objects. c 2003 Elsevier B.V. All rights reserved.
Keywords: Gray codes; Loopless generating algorithms; Multiset permutations; Shu7e combinatorial objects
1. Introduction
Let n0;n1;:::;nk be k + 1 integers. The set of multiset permutations (permutations with repetitions) of type n0n1 :::nk , denoted by S(n0;n1;:::;nk ), is the set of integer sequences in which there are ni occurrences of i,06i6k, and multiset permutations simultaneously generalize permutations and combinations. A Gray code for a class of combinatorial objects is a list for the class so that successive objects di:er in some pre- speciÿed small way [14]. In particular, a Gray code for the set S(n0;n1;:::;nk ) is a list for this set where successive sequences di:er by a transposition of two items. Agen- erating algorithm is loopless if after the initial sequence is generated, each succeeding sequence may be obtained by at most a ÿxed number of operations. Many algorithms for generating Gray codes for multiset permutations, looplessly [2,8,15] or otherwise [3,7,13], have been published. We present here a new loopless
E-mail address: [email protected] (V. Vajnovszki).
0304-3975/03/$ - see front matter c 2003 Elsevier B.V. All rights reserved. doi:10.1016/S0304-3975(03)00228-7 416 V. Vajnovszki / Theoretical Computer Science 307(2003) 415–431 generating algorithm for this combinatorial class. Our approach is the following: we express multiset permutations in terms of shu)e on trajectories (shu)e for short, in this paper), then we apply it to redeÿne a known Gray code (implemented, but not looplessly at [12]) and to obtain a new loopless generating algorithm for multiset permutations. The remainder of this paper is organized as follows. At the end of the present section we introduce the notations we adopt throughout this paper. In Section 2 we recall basic results and present the shu7e on trajectories constructor for combinatorial objects. The Gray code for multiset permutations based on this constructor and some of its properties are presented in Section 3. In Section 4 we discuss two known loopless generating algorithms for product set and combinations, and a loopless algorithm for multiset permutations is developed. Some concluding remarks are o:ered in the ÿnal section. If L is an (ordered) list for a set of integer sequences then ÿrst(L) is the ÿrst element and last(L) the last element on the list L; LE is the list obtained by reversing L, and obviously ÿrst(L)=last(LE ) and ÿrst(LE )=last(L); L(i) is the list L if i is E m even, and L if i is odd; if L1; L2;:::;Lm are m lists then L1◦L2◦···◦Lm = i=1 Li denotes the concatenation of these lists; if x is an integer or an integer sequence then xn is the sequence which consists of n copies of x; and L · x (x · L, respectively) is the list obtained by appending x to each sequence of L (each sequence of L to x, respectively). The rank of a sequence x in a list L, denoted rankL(x) (or rank(x) for short, if the list L is understood), is the number of sequences preceding x in L.
2. Preliminaries