An Upper Bound for Sorting with LRE
Abstract
A permutation over alphabet , is a sequence where every element in occurs exactly once. is the symmetric group consisting of all permutations of length defined over . = and are identity (i.e. sorted) and reverse permutations respectively. An operation, that we call as an operation, has been defined in OEIS with identity A186752. This operation is constituted by three generators: left-rotation, right-rotation and transposition(1,2). We call transposition(1,2) that swaps the two leftmost elements as . The minimum number of moves required to transform into with operation are known for as listed in OEIS with sequence number A186752. For this problem no upper bound is known. OEIS sequence A186783 gives the conjectured diameter of the symmetric group when generated by operations [1]. The contributions of this article are: (a) The first non-trivial upper bound for the number of moves required to sort with ; (b) a tighter upper bound for the number of moves required to sort with ; and (c) the minimum number of moves required to sort and have been computed. Here we are computing an upper bound of the diameter of Cayley graph generated by operation. Cayley graphs are employed in computer interconnection networks to model efficient parallel architectures. The diameter of the network corresponds to the maximum delay in the network.
Index Terms:
Permutation, Sorting, Left Rotate, Right Rotate, Exchange, Symmetric Group, Upper Bound, Cayley Graphs.I Introduction
The following problem is from OEIS with sequence number A186752: “Length of minimum representation of the permutation as the product of transpositions and left and right rotations . [1].” We call this operation as .
operation consists of following three generators: (i) that cyclically shifts all elements to left by one position, (ii) that cyclically shifts all elements to right by one position and (iii) that swaps the leftmost two elements of the permutation. The mentioned operations are abbreviated as , and respectively.
denotes whereas denotes the sorted order or identity permutation: . Sorting a permutation in this article refers to transforming into with operation. The alphabet is .
[2, 3] studied a more restricted version of this problem, i.e. operation where the operation is disallowed and appears in OEIS with sequence number A048200 [1]. We note that the results of [2, 3] are applicable to operation (that has not been studied) due to symmetry.
We seek to obtain an upper bound on the length of generator sequence that transforms with into .
The optimum number of moves to sort with are known only for ( and are our contributions). We give the first non-trivial upper bound to sort with .
Let be the array containing the input permutation. The element at an index is denoted by . Initially for all , .
We define a permutation as follows. The elements are in sorted order i.e. the largest elements of are in sorted order. is obtained by concatenating sublists and . Therefore a permutation can be denoted as follows .
Therefore, is which is and which is .
Let denote execution of Left-Rotate move followed by a Exchange move and denote execution of Right-Rotate move followed by a Exchange move. Further, let and be consecutive executions of and respectively. Similarly, let and be consecutive executions of and respectively.
I-A Background
A Cayley graph defined on Symmetric group , corresponding to an operation with a generator set has vertices each vertex corresponding to a unique permutation. An edge in from a vertex to another vertex indicates that there exits a generator such that when is applied to one obtains . Applying a generator is called as making a move. An upper bound of moves to sort any permutation in indicates that the diameter of is at most . An exact upper bound equals the diameter of . Cayley graphs have many properties that render them apt for computer interconnection networks [4, 5]. Various operations to sort permutations have been posed that are of theoretical and practical interest [5].
Jerrum showed that when the number of generators is greater than one, the computation of minimum length of sequence of generators to sort a permutation is intractable [14]. operation has three generators and the complexity of transforming one permutation in to another with unknown. Exchange move is a reversal of length two, in fact it is a prefix reversal of length two.
For sorting permutations with (unrestricted) prefix reversals the operation that has generators, the best known upper bound is [9]. In operation, both left and right rotate cyclically shifts the entire permutation. In contrast, [12] an extended bubblesort is considered, where an additional swap is allowed between elements in positions 1 and . We call an operation say symmetric if for any generator of its is also in . Exchange operation is inverse of itself whereas left and right rotate are inverses of one another, thus, is symmetric. Both and are restrictive compared to the other operations that are studied in the context of genetics e.g. [6]. Research in the area of Cayley graphs has been active. Cayley graphs are studied pertaining to their efficacy in modelling a computer interconnection network, their properties in terms of diameter, presence of greedy cycles in them etc. [15, 11, 13]. Efficient computation of all distances, some theoretical properties of specific Cayley graphs, and efficient counting of groups of permutations in with related properties have been recently studied [7, 16, 8, 10].
II Algorithm LRE
Algorithm sorts in stages. It first transforms which is identical to into by executing an move. Subsequently, is obtained from by executing the moves specified by Lemma 1. Thus, eventually we obtain which is identical to . Pseudo Code for the Algorithm is shown below.
Algorithm LRE
Input: . Output: .
Initialization: .
All moves are executed on .
II-A Analysis
Lemma 1.
The number of moves required to obtain from is .
Proof.
According to the definition, is
.
Executing on yields
.
An E move is executed to obtain
.
Finally, is executed to obtain
which is .
Therefore, the total number of moves required to obtain from is .
∎
Lemma 2.
The number of moves required to obtain from is 3.
Proof.
According to the definition, is
. Executing on yields
. Then executing an move yields
which is . Therefore, three moves suffice to transform into .
∎
Theorem 3.
An upper bound for the number of moves required to sort with is .
Proof.
Let be the number of moves required to sort with . According to Lemma 1, the number of moves required to obtain from is . Let be the number of moves required to obtain from (which is ). Then
According to Lemma 2, the number of moves required to obtain from is 3. Therefore,
Therefore, the total number of moves required to sort with is . Ignoring the lower order terms an upper bound for number of moves required to sort with is . This is the first non-trivial upper bound for the number of moves required to sort with . ∎
III Algorithm LRE1
We designed Algorithm in order to obtain the tighter upper bound for sorting with . We define a permutation as follows. The largest elements of i.e. are in sorted order. is obtained by concatenating sublists and . and differ by the starting position of sublist . The starting position of in is 1 whereas in it is . Algorithm first transforms into . Then it transforms into which is . Let and . Let be the number of moves executed by Algorithm to sort .
Input: . Output: .
Initialization: . ,
All moves are executed on .
III-A Analysis
Lemma 4.
The permutation obtained after executing D1 and D2 of Algorithm LRE1 is
and the number of moves executed is when n is even and when n is odd .
Proof.
Execution of E move on in yields
.
Then executing in yields
.
Then executing in yields
.
Then performing in move yields
.
Therefore, the total number of moves executed in step and is
∎
Lemma 5.
The permutation obtained after D3 and D4 of LRE1 algorithm are executed is and the number of moves executed in the above two steps is when n is even and when n is odd .
Proof.
From Lemma 4, the permutation obtained after steps and is
.
When in step only move is executed and permutation thus obtained is
.
When in step only move is executed and permutation thus obtained is
.
There after in each iteration in step , move, and are executed so that the elements between and are left rotated. Thus, the permutation obtained after step is and the number of moves executed in each iteration is .
Therefore, the total number of moves executed in step is
Execution of in step yields
which is . Therefore, the total number of moves executed in steps and are .
∎
Lemma 6.
The permutation obtained after executing D5 and D6 of LRE1 algorithm is
and the number of moves executed in the above two steps is when n is even and when n is odd .
Proof.
According to Lemma 5, the permutation obtained after the steps to is
.
Now, executing move in step yields
.
Then executing in step yields
.
Then executing in step yields
.
Therefore, the total number of moves executed in steps and is
.
∎
Lemma 7.
The permutation obtained after executing D7 and D8 of LRE1 algorithm is and the number of moves executed in the above two steps is when n is even and when n is odd .
Proof.
According to Lemma 6, the permutation obtained after steps to is
.
move is executed in step and the permutation thus obtained is
.
When in step D8, only move is executed and the permutation thus obtained is
.
When in step D8, only move is executed and the permutation thus obtained is
.
There after in each iteration in step except when , move, and are executed so that the elements between and are left rotated. When only move and are executed. Thus, the obtained permutation after step is . The number of moves executed in step is
.
∎
Lemma 8.
Algorithm LRE1 is correct.
Proof.
According to Lemma 7, the permutation obtained after steps to is
.
Executing move in step yields
which is . Hence proves the lemma.
∎
Theorem 9.
The number of moves required to sort with LRE1 algorithm is
J’(n) = .
Proof.
Case-i: is 3
When =3, the values of and are 1 and 2 respectively. So, only steps and are executed. Therefore, the number of moves executed are .
Case-ii: is 4
When =4, the values of both and is 2, So only steps , and are executed. Therefore, the total number of moves executed are .
Case-iii: is 5
When =5, the values of and are 2 and 3 respectively. So only steps , , and are executed. According to Lemma 6, the number of moves executed by steps and is when is odd. Therefore, the total number of moves executed are .
Case-iv: is 6
When =6, the values of both and is 3. Therefore steps , , , and are executed. According to Lemma 4, the number of moves executed by steps and is when is even. According to Lemma 6, the number of moves executed by steps and is when is even. Therefore, the total number of moves executed are .
Case-v: is 7
When =7, the values of and are 3 and 4 respectively. Therefore steps , , , and are executed. According to Lemma 4, the number of moves executed by steps and is when is odd. The number of moves executed by step is 2. According to Lemma 6, the number of moves executed by steps and is when is odd. According to Lemma 7, the number of moves executed by steps and is when is odd. Number of moves executed by step is 1. Therefore, the total number of moves executed is .
Case-vi: and is even
In this case all steps from to are executed. According to Lemma 4, the number of moves executed by steps and is when is even. According to Lemma 5, the number of moves executed by steps and is when is even. According to Lemma 6, the number of moves executed by steps and is when is even. According to Lemma 7, the number of moves executed by steps and is when is even. Number of moves executed by step is 1. Therefore, the total number of moves executed by Algorithm is
Case-vii: and is odd
In this case all steps from to are executed. According to Lemma 4, the number of moves executed by steps and is when is odd. According to Lemma 5, the number of moves executed by steps and is when is odd. According to Lemma 6, the number of moves executed by steps and is when is odd. According to Lemma 7, the number of moves executed by steps and is when is odd. Number of moves executed by step is 1. Therefore, the total number of moves executed by Algorithm is
Therefore, ignoring the lower order terms the new tighter upper bound for number of moves required to sort with is . ∎
IV Exhaustive Search Results
A branch and bound algorithm that employs BFS, i.e. Algorithm Search, has been designed for computing the minimum number of moves to sort for a given . It yielded values of 43 for and 53 for . Thus, including the current values, the identified minimum number of moves for for are respectively .
A list of permutations whose distance has been computed is maintained and the execution in every branch terminates either upon reaching or exceeding a bound. E, L and R generators are applied to each of the intermediate permutations yielding the corresponding permutations.
We avoid application of two successive generators that are inverses of each other as such a sequence cannot be a part of optimum solution. Notation: Node contains a permutation and its distance from corresponds to the minimum number of moves. With this algorithm and better computational resources one will be able to compute the corresponding values for larger values of .
Algorithm Search
Initialization: The source vertex contains the permutation and its path is initialized to null. It is enqueued into BFS queue .
Input:. Output: Optimum number of moves to reach with .
V Results
Comparison of the number of moves required to sort with by various algorithms. The first column shows , the size of permutation. Subsequent columns show the number of moves required to sort with Algorithms , and respectively.
n | LRE | LRE1 | Search(Optimal) |
---|---|---|---|
3 | 3 | 2 | 2 |
4 | 4 | 4 | 4 |
5 | 8 | 8 | 8 |
6 | 15 | 13 | 13 |
7 | 25 | 20 | 19 |
8 | 38 | 26 | 26 |
9 | 54 | 34 | 34 |
10 | 73 | 43 | 43 |
11 | 95 | 54 | 53 |
Conclusion
The first known upper bound for sorting with has been shown. A tighter upper bound has been derived. The future work consists of identifying the exact upper bound for sorting with . The identification of the diameter of the Cayley graph and the characterization of permutations that are farthest from in this Cayley graph are open questions.
Acknowledgement
Venkata Vyshnavi Ravella and CK Phani Datta have been contributing towards implementation, testing and analysis of the algorithms. Authors thank Jayakumar P for helpful suggestions. Authors thank Tony Bartoletti for personal communication.
References
- [1] The On-Line Encyclopedia of Integer Sequences: oeis.org.
- [2] Kuppili1 S. S., Chitturi1, B., and Srinath T., ”An Upper Bound for Sorting with LE,” ICACDS 2019.
- [3] Kuppili1 S. S., Chitturi1, B., ”Exact Upper Bound for Sorting with LE,” “Discrete Math Algorithms Appl”. 2020, doi.org/10.1142/S1793830920500330.
- [4] Akers, S. B., Krishnamurthy, B., ”A group-theoretic model for symmetric interconnection networks,” IEEE Transactions on Computers, 38(4):555–566, 1989.
- [5] Lakshmivarahan, S., Jho, J-S., and Dhall, S. K., ”Symmetry in interconnection networks based on Cayley graphs of permutation groups: A survey,” Parallel Computing, 19:361–407, 1993.
- [6] Chitturi, B., ”A note on complexity of genetic mutations,” Discrete Mathematics, Algorithms and Applications, 3, 269-286, 2011.
- [7] Chitturi,B., and Das, P., ”Sorting permutations with transpositions in amortized time,” Theoretical Computer Science, 2018.
- [8] Biniaz, A., Jain, K., Lubiw, A., Masárová Z., Miltzow, T., Mondal, D., Naredla, A.M., Tkadlec, J., and Turcotte, A., ”Token Swapping on Trees,” http://arxiv.org/abs/1903.06981, 2019.
- [9] Chitturi, B., Fahle, W., Meng, Z., Morales, L., Shields, C. O., Sudborough H., ”An (18/11) n upper bound for sorting by prefix reversals,” Theoretical Computer Science, 410(36): 3372-3390, 2009.
- [10] Chitturi, B., Computing cardinalities of subsets of with k adjacencies, JCMCC, (to appear) 2020.
- [11] Erskine, G., and James T., ”Large Cayley graphs of small diameter,” Discrete Applied Mathematics, 2018.
- [12] Feng, X., Chitturi,B., Sudborough, H., ”Sorting circular permutations by bounded transpositions,”, Advances in Computational Biology, Springer, New York, NY (2010), pp. 725-736.
- [13] Gostevsky, D.A. and Konstantinova, E.V., ”Greedy cycles in the star graphs,” Discrete mathematics and mathematical cybernetics, 15(0):205-213, 2018.
- [14] Jerrum, M. R., ”The complexity of finding minimum-length generator sequences,” Theoretical Computer Science, 36:265-289, 1985.
- [15] Mokhtar, H., ”A few families of Cayley graphs and their efficiency as communication networks,” Bulletin of the Australian Mathematical Society, 95, no. 3, 518-520, 2017.
- [16] Zhang, T., and Gennian G., ”Improved lower bounds on the degree–diameter problem,” Journal of Algebraic Combinatorics, 1-12, 2018.