SEALiP : A Simple and Efficient Algorithm for Listing Permutation via Starter Set Method

Algorithm for listing permutations for n elements is an arduous task. This paper attempts to introduce a novel method for generating permutations. The fundamental concept for this method is to seek a starter set to begin with as an initial set to generate all distinct permutations. In order to demonstrate the algorithm, we are keen to list the permutations with the special references for cases of three and four objects. Based on this algorithm, a new method for listing permutations is developed and analyzed. This new permutation method will be compared with the existing lexicographic method. The results revealed that this new method is more efficient in terms of computation time. | Permutation| Starter set| Lexicographic| ® 2013 Ibnu Sina Institute. All rights reserved. http://dx.doi.org/10.11113/mjfas.v9n4.108


INTRODUCTION
Permutation algorithms are one of the component from which all field of computer science grow.Permutation is the different arrangements that can be made with a given number of things taking some or all of them at a time.The applications of permutation are used in various fields such as mathematics, group theory, statistics, and computing.In general, permutation algorithms have received much attention in the literature [1,3,[8][9][10].Permutation algorithms can be classified into two main categories namely algorithms based on non-exchanged (random) and algorithms based on exchanged (lexicographic) [8].In addition to the random and lexicographic algorithms for generating permutation, there are other permutations algorithms such as: using sequences of permutation, choosing any elements of permutations, and using permutation matrices [1,5,6].Based on the methods mentioned above, we found that the most challenging task dealing with permutation is when n is large enough.For example, the value of n = 10! is 3628800.However, in real application problems we usually are dealing with more than ten or even hundred items.Thus, to design a simple and efficient algorithm for permutation generation is fundamental and a practical issue.
Most of the existing algorithms concentrate on listing all n! permutations.The advantage of this proposed algorithm is to produce some sets to begin with and these sets finally generate all the n! permutations.However, a work on generating starter set as basis to list n! was proposed in 2010 [2].Thus this paper aims to provide a method to list n! permutations based on starter set that will be discussed in section 2.3.The present paper is divided into two parts.In the first part various categories of permutation methods are reviewed whilst the second part focuses on the computation time.The comparison between proposed method and classical method such as lexicographic will be carried out at the end of the study.

PERMUTATION METHODS
This section will present discussion on permutation algorithms based on non-exchanged (random) and exchanged (lexicographic).Then we will provide another permutation algorithm based on starter set.

Permutation Algorithms Based on Non-Exchanged (random)
In this section, we are concerned on a variety of algorithms which not based on exchanges.These algorithms are for generating a random permutation that may be used to generate random cycles of length n instead.So some algorithms use random cyclic rotations to obtain the n! distinct permutations.The basic idea for generating permutation at random is to generate at random one of the n! sequences of integers k 1 , k 2 , ..., k n satisfying 0 ≤ k i < i (since k i is always zero, it may be omitted), and to convert it to a permutation through a bijective correspondence.For the latter correspondence, one could interpret the (reverse) sequence as a Lehmer code.The above algorithm for generating permutation was first published in 1938 by Fisher and Yates [4].
The basic algorithm given for generating a random permutation of the numbers 1-n goes as follows: Step 1: Write down the numbers from 1 to n.
Step 2: Pick a random number k between one and the number of unstruck numbers remaining (inclusive).
Step 3: Counting from the low end, strike out the kth number not yet struck out, and write it down elsewhere.
Step 4: Repeat from step 2 until all the numbers have been struck out.
Step 5: The sequence of numbers written down in step 3 is now a random permutation of the original numbers.

Permutation Algorithms Based on Exchanged (Lexicographic)
Permutation algorithms that based on exchanged n! permutations of n are usually obtained by a series of (n!-1) exchanges [8].Thus, this algorithm when applied to permutations, the lexicographic order increases in numerical order (or equivalently, alphabetic order for lists of symbols).There are many ways to systematically generate permutations of a given sequence.One classical algorithm, which is both simple and flexible, is based on finding the next permutation is lexicographic ordering.This technique generates the distinct permutations by converting to permutations, one starts by sorting the sequence in increasing order (which gives its lexicographically minimal permutation), and then repeats to the next number.
The following steps show how to generate permutation lexicographically and transform the given permutation: Step 1: Find the largest index j such that a[j] <a[j + 1].If no such index exists, the permutation is the last permutation.
Step 2: Find the largest index l such that a[j] <a[l].If l exists and satisfies j < l, j+1 is such an index.Strictly speaking, if the n items going through permutations are ordered by a precedence relation "<", then permutations   = � ,1  ,2 …  , � precedes permutation   = � ,1  ,2 …  , � if and only if, for some i ≤ 1, we have  , =  , for all j <i and  , =  , .

Permutation Algorithms Based on Starter sets
A new algorithm for generating permutations by choosing any elements of permutations was found by Rohl [6].The purpose of this algorithm is to give a simple, general algorithm which will produce arrangements of n symbols taken r at a time where the symbols may or may not be distinct.Various procedures based on the algorithm are presented, some producing the arrangements in lexicographical order, some not.The algorithm is easy to use as the basis for a solution to some combination problems.But we noticed that no timing information had been provided.The reason is that this algorithm is not designed specifically for its execution time but for its adaptability specifically to a wide variety of problems.
An algorithm for generating permutations by using permutation matrices was proposed by Mani [5].The algorithm is proposed in an original technique, by using a cyclic of permutation matrices' rotations.The only restrictions on the implementation language are the availability of a function and efficient pointer manipulations.
This section will examine the other algorithm for generating all permutations by using combinatorial approach that was developed by Ibrahim et al. [2].Notably, this new algorithm for listing all permutations for n elements was developed based on distinct starter sets.Hence, once the starter sets are obtained, each starter set is then cycled to obtain the first half of the distinct permutations.The complete list of permutations is achieved by reversing the order of the first half of the permutation.This algorithm has advantages over the other algorithms due to its simplicity and ease of use.
The followings definitions are needed in the following sequel for algorithm development.

Definition 2.3.1. A starter set is a set that is used as a basis to enumerate other permutations.
Definition 2.3.2.A reversed (inverse) set is a set that is produced by reversing the order of permutation set.

Definition 2.3.3. An equivalence starter set is a set that can produce the same permutation from any other starter set.
We will provide two different cases to generate 3! and 4! permutations before we develop the general algorithm for this method.
Case 1: 3! = 6 distinct permutations.Here we will provide steps to list all six distinct permutations.

{1, 2, 3}
Step 4: Generate distinct permutations from this starter set.Step 5: Find the reverse of the above permutations.

Permutation algorithm based on starter set
Step 1: Step 2: Step 3: Step 4: Step 5: Step 6: Step 7: Fix one element Determine other starter set Determine the equivalence starter set and eliminate this set.Repeat step 2-3 to produce all distinct starters.Cycle each starter to get n!/2 permutations Reverse the order of each n!/2 permutation to get another n!/2 permutations List all n! permutations

PERFORMANCE OF PERMUTATION ALGORITHMS
Several algorithms to generate permutations have been presented such as lexicographic algorithm and random cyclic algorithm.All these algorithms have their strengths and weaknesses from the viewpoint of the efficiency evaluation.For example, lexicographic algorithm uses more execution time to make the strictly-ordered permutations.This algorithm happens to repeat the same permutation again, and the repeated permutation is actually not needed [1,6,8].Random cyclic algorithm has the same problem in terms of execution time to generate permutation [5,8].The most familiar and well-known algorithm used to find all permutations is called a lexicographic algorithm.A lexicographic algorithm as we mentioned earlier requires more time to find all permutations [1,6,8].
The proposed permutation algorithm based on starter set is as an endeavour to improve the performance of the algorithm to generate permutation [2].In this section we compare the proposed permutation algorithm based on starter set with the lexicographic permutation algorithm.
The efficiency of both algorithms can be computed in terms of the execution time.We have used permutation algorithm for starter set as described in section 2.3 and lexicographic algorithm as discussed in section 2.2.The pseudo code for both algorithms can be found in [7].Table 1 enumerates algorithms for lexicographic and starter set for n = 4 elements.While the efficiency of both algorithms was computed in terms of the execution time.Based on several tests conducted on different order of n elements, the results stated in Table 2 show the value in seconds for the execution time of the lexicographic algorithm and starter set algorithm.We can see that results of the execution time of the starter set algorithm are less than the lexicographic algorithm (see Fig. 1).This computation time have been implemented by using MATLAB version 7 and were performed in laptop Acer 5635Z (Pentium 800 MHz CPU, 3 MB of main memory).

CONCLUSION
We have presented a new method to list n! permutations based on starter set.The results show that this new method has less computation time.Based on the discussion on this study these three following questions arise: • Could we construct isomorphism classes to classify equivalence starter sets?We expect to use onefactorization or decomposition of compete graph (K n ).• Could we employ these new algorithms (permutation based on starter set) in other fields, for example in cryptography (security), image processing?• Could we determine the starter set without fixing any positions?

Step 3 : 4 :
Swap a[j] with a[l].Step Reverse the sequence from a[j + 1] up to the final element a[n].
3 2 1).Here are the permutations based on the steps explained above

Fig. 1
Fig. 1 Comparison of the execution times between the starter set algorithm and lexicographic.

Table 1 .
Lexicographic order and starter set order for n=4!

Table 2 .
The execution time (in seconds) for Lexicographic and starter set algorithm .