Click here to load reader
Upload
stefan-pleszczynski
View
221
Download
2
Embed Size (px)
Citation preview
’
.-. 4
::
V&me 3, n\lm&ex 6 INFORMATION PROCESSING LETTERS July 1955
.’
$djoi&&$ as an initial digit to each facto&! represen- $&on f&n &?,_I. It follows that a permutation as- a@ied b;L rulle R n to a fact,orial represeritation in elDId ,is s&h that k,,, = s and (&_2, . . . , ko) are specified by ruie R,_l applied to (~~-2~ . . . , cl), with the only mo#@~w, t@t an*bjsct lma&ed by 3” is now re- .pla&d~~y ~@oJ$ct marked by % - 1”. Consequently. thea&rr$ption that RN._1 is a one-one ttansforma- tion from C! “_ I onto& _], implies the corresponding statement for R,.
4. Generatio rule
It is easy .to note that Ra induces an ordc ring of permutations in K,, according to the serial numbers represented by corresponding factorial representations. To illustrate, for n = 4 we present in table 1 the se- quence of permutations in X, iti the order induced by 84..
‘The problem of pra&cal generating of ail permuta- tions in this particular order is reduced to the follow-
TfBle 1
Serhl
number
23 22 21 20 19 18 19 16 1s lc) 13 12 11 10 9
: 6 5 4 3
j 2 1 0
FWtOIial
mprosentation
ts,a, 1, (3, go> (3.1.1) (3.1.43, 23.0, f) <3,0,0) (2,&l) f2,2,0, (2.1.11 (2.1.0) (2.0.1) (2,0,0) <I,2 1) !1,2,0> (l,l,l) (l,l,O, Cl, 0,l) (l,O,O) (0,2,1, <0,2,0, <O,l, 1) (O,l,O) f40.1, (o,ao)
Permutation
(392. LO1 13,2,0,1)
j 13,1,2,0) I3.1,0,2) (3,0,1,21 (3,O. 2,l) (2,3. LO) (2,3,0,1) (2,1,3,0) (2,1.0,3) Q,O, 1,3) (?,O, 3,l) 11,2,3,0) U*2,0,3) (1,3,2,01 t1,3,0,2) (1,0,3,2) (1,0,2,3) (0,2,1,3) (0,2,3.1) (0,1.2,3) (0, 1s 392) <0,3,1.2) to. 3,&l)
ini one: for a given factorial representation (cn_l, . . . , Cl) of so? ~ .lumbet L and for the corre- spondinf: permui:: ‘WI <:k~,__~ .., ko), generate the next permutation (kJt_l , . . . , !.b) which would be as- signed by R, 10 the number L - 1.
Since f+f any L > I there exists a subscript j, 0 < j < n, such that C~ # 0 and cl-l z *es = cl, = 0, the faciorii representation ofL - I equaIs ~;r_~, . . . ,cj+l,
c;, c;-1 , . . . , Ci with .ci = cl- I and ci = E’ for i = 1 , . . . , j - 1. Consequently, in view of the definition of R, , (n - j - 1)th degree permutations induced by factorial representations of L and of C - 1 are identi- cal, and k; - ki for i = n - 1, . . . , [ + 1.. Moreover,
&t-l I -.. , ki+ 1, kj, kj__l, . . . , kb) is formed directly frctm the (n - I- 1 ):h rdegree pcrmuta tion by a mutual exl:hange of objects COTL bonding to posi iio ns cj and j;&iriisasimpleconsequ&eof~~=ifori=1,...,j-1 an3 of the defmition of R,. But cl = ci - 1 and there- fore the next permutation can be generated according to the following rules: 1. Find j which is the Ieast i such that ci # 0,
E= !,._.,rr - 1. 2. Reconstruct the (n - j - 1 )th degreie permutation
from (kn_l, . . . , ko) by: a) one-position-left cyclic shifting of the string of
objects corresponding to positio.ns j - 1, . . . , 0; b) transposing objects appearing on positions ci
and j. 3. Transpose objects appearing on pos;itions cl - 1
andj.
Emnnp&:?.,et&=3960=5x720+3x120=5~6!+3x5!. Thus the factorial representation of L is (5 I 3,O,O,O,Ok Rule Rn ass&m to .k the permutation (5,3,0,4,6,2,1); thus ac- cording to the foregoing rules: 1. j’s; 2a.(S,3,0,4,ti,2,1)isshiftedto12,3,J,6,2,1,0); 2b.inviewofr~=3andj=~Sweget(5,6.4,3,2,1,~; 3. the result id (5,2,4,3,6,1,0); this permutation cor?c;-
spends, of course, to the number 3959.
A realisation of these ideas is presented in the Ap-
pendix in the form of 2 simple procedure (in A&Hike notation) called NEXT PERJWTATION; integer ar- rays C and P appearilrg in this procedure correspond to the factorial representation of the given number L and to the permutation assigned to L by R,, respec- tively; to generate all the n! permutations it is OdY needed to start with C = (n - 1, . . . , 1) and P= (r: - 1, . . . . 0).
6 -.i wFi.XUfAT1ON PRWWSiNG tJ$TI’ERS hly 1975 ,’
b SSMATION. This procedure allows us io determine a factorial representation (integer array C) which cor-
~~.; .~~~vM~LNEXTM~~C~AT..~~ responds (according to R;l) to a given permutation . . t 6’ ., ’ of n objects marked ‘O”, . . . , “n - 1” (integer array P). ::.; fi #a w to note xhat the procedure NEXT PERMU- This procedure is believed to bti useful mostly in vari-
tes next pamutation after performing ous operation research programs dealing with permu- in .‘the foregoing example I = S); tations, because computer manipuiatious with permu-
qqesaive .rzro!J %l the Ieast tations tire less convenient than the anatogous manipu- afactoiial repreknt@3k oft. lations with their serial numbers.
q@ .%il” zeros in factorial rep n,icgeas in the interval p, pt! - 11.. _
A~pendk
gmcwhrewExT PERMWTATION(C,~',H); iwqpn;
the totd number of iteratiotts, say Qs, MlpmYc,P; ( b*integeri,l,k,nrr ’
i .i :t Q;
B:f:=i+ 1:
“ ,g#:@wr $j ;, i := cp: A:rC~:=IPI:=O.thenisbs/-l; 1 :=pj,
‘PI;:= Pi; pi :=Pk; Pk :-r m; Ij=bAk#n-1 thehptol,
less than e y 1 &rations ke net- .a4 next pemmtatiozt. Acomputer
tion is very rapid so that the pro&ore PERMUTATION (C, P, n); ef’@ent, alth@h the Jateger n; of two &jects pkerform- intkgez my C, P,
It L kW minima. An aIgorithm wit& a mir&nal .beghhtqwi,~,k;
K of eManger is given in [ 1 fR but t&‘alg;o- brn:=n-twhifen>Odo
rsnlnr to it& to a more complicated compurier
; WfpwJl, / := C&
I : ‘:>__ 5)
IAL REPRESENTATlON (C, P, n):
nted by a factorial repre
,.ez: 10f>nthen ., begin
--&%.5&m FAC'lWiIAL JUT!U?SENNT,s fiON i := cj; WWE
volume 3. number 6 INFORMATION PROCESSING LETTERS July 1975
References [2 j Mark B_ Wells. Generation of Permutations by Transposi- tion, Wat’iematics of Computation 15 (1961) 192- 195.
(11 Sehner M. iohnson, Generation of Permutation by Adja- cent Transposition, Mathematics of Computation 17 (1963) 28&2”5
[ 31 Andrzej Kielbaai: F ;, Ptoc&t*ra permutacje, Prace ZON, Wydewnictw , i :IY :rsvtet:~ iijarwwskiego (1967).
; t
: