VO. 10, NO. 18, OCTOBER 2015 ISSN 1819-6608 GRAY CODE FOR GENERATING TREE OF PERMUTATION WITH THREE CYCES Henny Widowati 1, Suistyo Puspitodjati 2 and Djati Kerami 1 Department of System Information, Facuty of Computer Science and Information Technoogy, Gunadarma University, Indonesia 2 Department of Informatics, Facuty of Industria Technoogy, Gunadarma University, Indonesia Department of Mathematics, Facuty of Mathematics and Natura Sciences, University of Indonesia Gunadarma University, J Margonda Raya Depo Indonesia E-Mai: djatikr@ui.edu ABSTRACT This paper present a new Gray code formed from generation tree of n-ength permutation with three cyces. Gray code is a ist of a the objects arranged such that, there are ony minor differences between one object to another object. To be effective, isting of a objects is done with successive generation, where the structure-i th is determined by structure-(i- 1) th. The isting agorithm is done by finding a method or agorithm for isting a objects in a certain order without any repetition and without osing any of the objects, so that two successive objects differ sighty. Combinatoria Gray code is widey used, for exampe, in circuit testing, hardware and software testing, encryption, data compression, and games. The purpose of this research is to deveop a new Gray code that formuated from generating tree of n-ength permutation with three cyces proposed by Puspitodjati. The Gray code formuated by traversing the generating tree of permutation with three cyces. It is a modification of Bernini s Gray code formuation for Cataan number generating tree. The Gray code then anayzed by measuring the Hamming distance of each two successive words of the ist and it is of a Hamming 1. Keywords: combinatoria gray code, generating tree, n-ength permutation with three cyces, hamming distance. INTRODUCTION Combinatorics is the study of mathematica properties of discrete structures. Combinatorics has four main branches of science: enumeration, generation, isting, and optimization. Initiay, combinatorics studies ony enumeration of combinatoria objects in a combinatoria cass. Combinatoria cass or cass is caed the set of combinatoria objects, whie the combinatoria objects itsef caed object. isting of a combinatoria object, is to buid an agorithm to generate a possibe structures of S where the i th -structure is determined from the (i-1) th -structure or the structure of ength n associated with the structure of ength (n-1), and have a sma Hamming distance. ist a combinatoria objects arranged in a way that there is ony a minor difference between one object and the next object, known as combinatoria Gray code. Savage in [1] defines 'sighty different' as different in 'some pre-specified, sma way'. Ruskey in [2] defines 'sighty different' of one object to the next object in genera as a member of the coseness reations of a cass of objects being isted. One of a coseness reation is Hamming distance, where two successive objects differ in a certain constant. If the constant number is minima then the Gray code is said to be optima. A Gray code is said to be cycic if the first object and the ast objects differ sighty, or in genera, it satisfies the coseness reation. Bernini in [] defines a Gray code as a finite set of string ists, with infinite string ength, so that the Hamming distance between two consecutive strings is imited. Bernini aso discusses a famiy of combinatoria Gray code based on generating trees, which codes obtained by traversing nodes in the generating tree. A previous research on Gray code of permutations with a given cyces, has performed by Bari in [4]. Bari buid Gray code isting agorithm wherein the formuation is divided into five cases based on the reation between the number of cyces and the size of permutations. Mapping of the permutations with cyce to the array of transposition, produce a ist of string where every consecutive two strings differs at most in two positions, and stricty defined by Bari as a Gray code. Bernini in [] and Vajnovszki in [5] deveoped a Gray code of severa combinatoria objects, incuding permutations based on the succession rues (rues of branching tree) of an ECO (Enumerating Combinatoria Objects) system. Bernini in [] defines a procedure to encode and to ist objects of Cataan numbers such that two consecutive objects differ by one-digit. Gray structure is defined as an object of combinatoria cass which construction meets a succession rues that have a stabiity property. Gray code that deveoped from generating tree for n-ength permutation with two cyces has been proposed by Puspitodjati as in [6]. Gray code resuting from the transformation, as Bari in [4], as we as the encoding of the succession rues (generating trees) by Bernini in [], became the basic idea of this paper. This paper buids a Gray code isting formuation with the encoding of generating tree of permutation with three cyces as a combinatoria object. The generating tree that becomes combinatoria object of this research is Puspitodjati s generating tree of permutations with cyce as in [7]. Puspitodjati in [6] aso deveoped a Gray code that deveoped from generating tree for n-ength permutation with two cyces. But the way Puspitodjati formuated the Gray code of generating tree of n ength permutation with two cyes, coudn t be appied for generating tree n-ength permutation with three cyes. 8200
VO. 10, NO. 18, OCTOBER 2015 ISSN 1819-6608 Whie Bernini s approach in [], performed a traversa with a particuar procedure on such tree and found reguarity on nodes isting at a certain eve. Bernini shows that interestingy, the reguarity is inherited by the reguarity of nodes at the previous eve. This approach then becomes an idea to formuate a new Gray code that present in this paper. GENERATING TREE A generating tree is an infinite rooted tree. The root (at eve 0) abeed as e 0. Each branch has a node abeed (k) and has a reation with the next node at a greater eve. The systematization of the reation of each node to the next node summarized in a rue caed the succession rue Banderier in [8]. A generating tree for a cass of combinatoria objects coud appy if there is a bijection from the size of the object to the number of nodes at eve d of the tree. As an exampe is the generating tree for Cataan numbers, as in Figure-1. permutation 42165 means (1) mapped to 4, (2) mapped to 2, through (6) mapped to 5. A cyce of ength m in a permutation is a sequence of distinct eements a 1, a2,..., am such that a ( a 1 ) for i = 2,,..m and a ( a ). Such cyce i i 1 m is written as ( a 1, a2,..., am). A permutation can be decomposed into the disjoint unions of their cyces. For exampe, a one ine notation of permutation 42165 woud be in a cyce notation as (1 4 ) (2) (5 6). GRAY CODE ISTING FOR THE GENERATING TREE OF PERMUTATION WITH THREE CYCES Puspitodjati in [7] formuated the generation of n- ength permutations with m cyces. Based on the formuation, generating trees of n-ength permutation with three cyces for the first three eves is presented in Figure- 2. The generating tree in Figure-2 can be described according to the ECO succession rue () from [7]. Figure-1. Cataan number generating tree. The tree has systematized and the succession foows the rues as in (1) as foows: 2 k 2... k k 1, (1) k 2 Bernini in [] proposed a formuation of visiting nodes on the generating tree of objects count by Cataan number as in Figure-1, thus formed a Gray code, with the introduction of a shifted production function s( i) as foows: s 2 2, k 1, k 1,..., 4, s i i, i 1,..., k 1, k 1,2,,..., i 1 The four-digit Gray codes generated from (2) for the generating tree of the Cataan numbers are: [2222, 222, 22, 224, 222, 22, 24, 2, 24, 244, 245, 242, 222, 22]. (2) Figure-2. S n5 generating tree When the tree in [7] coded such that nodes abeed as the number of their chidren, the generating tree of n-ength permutations with three cyces then has a succession rues formuated in () as foows: 0 1 2 k k 1 k 2... eve 2 The new tree formed from the generating tree of n-ength permutation with three cyces, to eve 5, can be seen in Figure-. () PERMUTATION WITH CYCES A permutation of a set [n] = {1, 2,,..., n} is a one-one onto function : [n] [n]. Permutation can be written in a one ine notation, which sequence shows the sequence of mapping of [n]. For exampe, the 6-egth 8201
VO. 10, NO. 18, OCTOBER 2015 ISSN 1819-6608 Proof Mathematica proof is done by induction on d. For base d = 1, then 1 = [, 2, 1], it is ceary different by 1 digit or have a Hamming distance of 1. For inductive hypothesis: assume that it is true for d = 2,..., r, then formua (4) and (5) appies. Figure-. The summary of Sn, generating tree. Using a simiar Bernini strategy as in [], and conducting some modifications, this research formuates the rues of Gray code generation for the generating tree of permutation with three cyces as wi be described in the foowing section. GRAY CODE ISTING AGORITHM FOR THE GENERATING TREE OF Sn, PERMUTATION The new combinatoria Gray code of Puspitodjati s generating tree of n-egth permutation with three cyces in [8] formuated using these notations and definitions: d = ist of code with ength d digit/eve d d = [ d,1, d,2, d,, ] M = d-1 = cardinaity of d -1 x = most right digit x = mutipe concatenation = concatenation If is a ist of code, then: first() states the first eement of and ast() states the ast eement of Theorem-1: ist d formed in the foowing manner is a Gray code with Hamming distance of 1 1 = [, 2, 1] M d d, i i1 d and d, i defined by: max(d ) 1 d, 1 d1,1 s d1,1, max( d, d > 1, where M = d -1 (4) ) (4) ast (5) d, i d1, i s d1, i, d, i1 Inductive step for d > r+1, each eement d, i is formed with one digit different, so it ony needs to proof that ast( d,i ) and first( d,i+1 ), for 1 i M-1, are different by 1 digit. If J is the ast eement of s ast( )), then ast ( d1, i d, i1 ). Whereas d, i1 is obtained through ( d, i d1, i J d, i1 d1, i1 s( d1, i, ast( d, i1)) d1, i1 s d1, i1, J By the definition of shifted ist of the successors first s j j becomes s j the eement of, first( d, i1 ) d1, i1 J. So d 1, i and d1, i1 are different by 1 digit, by ast d, i and f irst d, i1 are different by 1 digit. mathema-tica induction, as we as GRAY CODE ISTING FOR THE GENERATING TREE OF Sn, PERMUTATION Based on the agorithm described above, the Gray code for a singe digit (d = 1) has been determined as 1 = [, 2, 1]. Furthermore, the Gray code isting is formed using an agorithm that has been formuated with one digit Gray code as input to obtain a two-digits Gray code (d=2). The d-digits Gray code isting is then obtained by (d-1) digits Gray code input. Here are the steps of Gray code isting for a generating tree of n-ength permutation with three cyces: Gray code for a generating tree of n-ength permutation with three cyces: One digit Gray code, d= 1: 1 Two digits Gray code d = 2, then max (d) = + 2 1 = 4. The two digits Gray code 2 = [,, 2, ], with a set of one digit Gray, as input, resuted as foows. code 1 has,, and from (4) 1,1 1,1 d) s,4 4 4 1,1 s 1,1, max( where: ( j, j 1, j 2,..., k 1) s ( j) ( j, max( d), max( d) 1,..., k 1) if if j max( d) j max( d) Furthermore by (5) coud be determined where 8202
VO. 10, NO. 18, OCTOBER 2015 ISSN 1819-6608 ast 4 4, 1,2 2 and 1,2 2,, so that from 1 1,2 s 1,2, ast 2, 1 2 s2,4 24, 2. ikewise, the member of 2, where ast 2, from 1, we obtain 1, and 1, 1, 1, are obtained 2, 1, s1,, ast 2, 2 1 s1, 1,14,12, so 4, 24, 2,1,14,12 that 2 Three digits Gray code The three digits Gray code is formed by utiizing 4, 24, 2,1,14,12 the set of two digits Gray code 2 The determination of, 1 is obtained with regard to 4, 4 and max(d)=5, then d) 4 s4,5 4 5 45,1 s, max( Furthermore by (5), since ast,1 45 5, and 24, 4, then,2 (, 1 s, ast( )) 24 s(4,5) 245. As we as the member of, where ast,2 245 5, and 2, 2,, so that 2,, 2, s 2,, ast, 2 2 s,5 25, 24 The determination of 4 regarding the vaue of 2 1, 2,4, ast, 24 4 gives,4 2,4 s 2,4, ast, 1 s,4 14,15 The determination of 5 regarding the vaue of 2 1, 2,5 and ast,4 15 5 gives,5 2,5 s2,5, ast, 4 14 s 4,5 145,4,5 The determination of, 6 regarding the vaue of 2,6 1, 2,6, and ast,5 145 5, gives,6 2,6 s2,6, ast, 5 Hence 125,124,12 =[45, 245, 25, 24, 14, 15, 145, 125, 124, 12] If the cacuation procedure continues then the Gray code for the generating tree of n permutation with three cyces for 4 digits is as foows: 4 = [456, 2456, 256, 246, 245, 145, 146, 156, 1456, 1256, 1246, 1245, 125, 124] The agorithm corresponds to the formuation of Gray code for the generating tree of permutation with three cyces is as foows: Agorithm-1 GraycodeGTS n, (d) 1. var i 2. begin. =[, 2, 1] 4. max(d)= +d-1 5. N = 6. (1)= GraycodeGTS n, (d-1) s((1), max(d)) 7. for i= 2,, N 8. (i)= GraycodeGTS n, (d) s((i), ast((i-1))) 9. end i 10. end CONCUSIONS The isting Gray code for the generating tree of permutation n with three cyces is successfuy formuated based on Puspitodjati s generating tree for permutation with cyces. The formuation is a modification of the Gray code isting formuation proposed by Bernini []. The modifications is on the definition of shift production s( j) and the determination of max (d), resuting in the isting agorithm of Gray code for the generating tree of permutation n with three cyces. This research has produced a compete generation agorithm; a objects appear and without repetition, and isted according to the concept of optima Gray code, i.e. between two consecutive objects have a Hamming distance of 1. REFERENCES [1] Savage C. 1997. Survey of combinatoria Gray codes, Journa SIAM Review archive, vo. 9, pp. 605-629, 820
VO. 10, NO. 18, OCTOBER 2015 ISSN 1819-6608 Society for Industria and Appied Mathematics Phiadephia, PA, USA. [2] Ruskey F. 200. Combinatoria Generation, http://www.1stworks.com/ref/ruskeycom bgen.pdf, 19 August 2007. [] Bernini A., E. Grazzini, E. Pergoa, R. Pinzani, 2007. A genera exhaustive generation agorithm for Gray structures, Journa Acta Informatica. 44(5): 61-76. [4] Bari Jean-uc. 2006. Gray code for permutation with a fixed number of cyces, Universite de Bourgogne, B. pp. 4780, 21078 Dijon. Cedex, France. [5] Vajnovzki V. 2012. ECO-Based Gray Codes Generation for Particuar Casses of Words, GAS Com 2012. http://v.vincent.ubourgogne.fr/0abs/pubi.htm. [6] Puspitodjati S., H. Widowati, A. Juarna, Djati Kerami. 2014. Combinatoria Gray Code for Generating Tree of Permutation with Two Cyces, ARPN Journa of Engineering and Appied Sciences. 9(12). [7] Puspitodjati S. 2010. Pembangkit engkap Permutasi Sikus Tertentu dengan Banyaknya Eemen sebagai Peubah, Disertasi Program Doktor Teknoogi Informasi Program Pasca Universitas Gunadarma. [8] Banderier C., M Bousquet-Meou, A. Denise, P. Fajoet, D. Gardy and D. Gouyou-Beauchamps. 2002. Generating Functions for Generating Trees, Discrete Mathematics. 07: 1559-1571. 8204