Optimal Algorithms for Sorting Permutations with Brooms

: Sorting permutations with various operations has applications in genetics and computer interconnection networks where an operation is speciﬁed by its generator set. A transposition tree T = ( V , E ) is a spanning tree over n vertices v 1 , v 2 , . . . v n . T denotes an operation in which each edge is a generator. A value assigned to a vertex is called a token or a marker . The markers on vertices u and v can be swapped only if the pair ( u , v ) ∈ E . The initial conﬁguration consists of a bijection from the set of vertices v 1 , v 2 , . . . , v n to the set of markers ( 1,2, · · · , n − 1, n ) . The goal is to sort the initial conﬁguration of T , i.e., an input permutation, by applying the minimum number of swaps or moves in T . Computationally tractable optimal algorithms to sort permutations are known only for a few classes of transposition trees. We study a class of transposition trees called a broom and its variation a double broom . A single broom is a tree obtained by joining the centre vertex of a star with one of the two leaf vertices of a path graph. A double broom is an extension of a single broom where the centre vertex of a second star is connected to the terminal vertex of the path in a single broom. We propose a simple and efﬁcient algorithm to obtain an optimal swap sequence to sort permutations with the transposition tree broom and a novel optimal algorithm to sort permutations with a double broom. We also introduce a new class of trees named millipede tree and prove that D ∗ yields a tighter upper bound for sorting permutations with a balanced millipede tree compared to D (cid:48) . Algorithms D ∗ and D (cid:48) are designed previously.


Introduction
Sorting permutations with various operations has applications in genetics and computer interconnection networks [1][2][3][4] and is an active field of research.Reversals, transpositions, prefix reversals, prefix transpositions have been extensively studied with respect to upper bounds, lower bounds, exact distances for all permutations in S n etc. Transposition tree is one such operation which has applications in solving puzzles and robot motion planning [5,6].
Hypercube architecture was a golden standard in 1980s for computer interconnection networks.Later, Akers and Krishnamurthy [1] proposed a transposition tree called star, and showed that the Cayley graph corresponding to star, called star graph can accommodate n! nodes and has diameter sub-logarithmic in number of vertices.Star graphs surpass the then topology Hypercube, both in scalability and diameter because the later can accommodate only 2 n vertices and has diameter logarithmic in number of vertices.Diameter is an important quality of service parameter deciding the latency of interconnection networks [7,8].There is a natural trade-off between diameter and the cardinality of the generator set.That is, a larger generator set decreases the diameter and vice-versa.The diameter of a Cayley graph Γ, can be trivially reduced to 1 if the degree of each node in Γ is one less than the total number of nodes.However, if the number of symbols, i.e., the label length of a vertex is n, then this would require the degree to be n! − 1 and this is infeasible.Thus, a good balance is sought.In this regard, the degree of Γ generated using any transposition tree is a relatively small value of n − 1 and for some trees the diameter can be small as well.For example, for a star graph the diameter is 3/2n + O(1) [1].Thus, Cayley networks were established as a better topology than hypercubes for interconnection networks.Cayley networks also possess other desirable features such as vertex symmetry and small diameter [1].These are detailed in Heydemann [3], Lakshmivarahan et al. [4], and Xu [8].
In this article we study the problem of sorting permutations under the operation specified by specific transposition trees-single broom, double broom and millipede tree.A transposition tree T = (V, E) is a spanning tree over n vertices v 1 , v 2 , . . ., v n .T denotes an operation in which each edge is a generator [1].A value assigned to a vertex is called token or marker.The markers on vertices u and v can be swapped only if the pair (u, v) ∈ E. This is equivalent to applying the corresponding generator and is referred to as making a move.Since swap is symmetric, the edge (u, v) is undirected.The initial configuration consists of a bijection from v 1 , v 2 , . . .v n to (1, 2, • • • , n − 1, n); i.e., from the set of vertices to the set of markers over the alphabet {1, 2, • • • , n − 1, n}.That is, one can view each vertex v i as an index i in an array where some marker j resides.Thus, input consists of a permutation.The vertex v i is the home for the corresponding marker i and we seek to home all markers with minimum number of moves.Note that if for all i, v i = i then the permutation is sorted.Thus, the goal is to sort the initial configuration, i.e., an input permutation, by applying the minimum number of generators (or swaps or moves) of T. In the remainder of the article, 'sorting' refers to transforming a given permutation into the identity permutation with a minimum number of moves of T.
The computational complexity of sorting permutations with transposition trees is unknown in general.However, computationally tractable optimal algorithms to sort permutations are known for a few classes of transposition trees such as star [1], path [9], broom [5,6,10], etc.
We study the problem of sorting permutations with a single broom and a double broom transposition trees.A broom, also referred to as a single broom, is a transposition tree obtained by joining the center vertex of a star with one of the leaf vertices of a path.Several efficient optimal algorithms are known to sort permutations using a broom [5,10,11].In Section 3 we design a new efficient optimal algorithm for sorting permutations using single broom.In Section 4 we design a novel efficient optimal algorithm for sorting permutations using double brooms.This algorithm is designed by extending the algorithm for single broom.The problem of sorting permutations using a new class of trees called millipede tree, is studied in Section 5. Section 6 demonstrates the limitation of the proposed algorithms when performed on an n-Broom providing a new direction for future research in the field of sorting permutations using transposition trees.

Preliminaries and Background
In this article, we employ the alphabet {1, An operation G is specified by a generator set that is a subset of S n ; G ⊂ S n .Each permutation in the generator set is a generator.Let π be a permutation in S n , and σ be a generator.Applying σ on π yields another permutation, say γ ∈ S n .We say that σ transforms π into γ.Given two permutations α, β ∈ S n , and an operation G, the minimum number of generators of G required to transform α into β is called the distance from α to β under G, denoted by d G (α, β) and in general, it is hard to compute the same if the number of generators is two or more [12].When G is symmetric, then d G (α, β) = d G (β, α).If the target permutation is I, then d G (α, I) is succinctly denoted as d G (α), which is called the distance of α.Transforming α into I is called as sorting α, and thus d G (α) is the number of generators required to sort α parsimoniously.Let g 1 , g 2 , . . .g t be a shortest sequence of generators such that α That is, the number of moves required to transform α into β is same as that of transforming β −1 • α into the identity permutation I. Thus, the problem of finding minimum distance between two given permutations reduces to the problem of sorting a related permutation.If the target permutation is Various operations have been studied in the past.Some of them are reversal, transposition, block interchange, etc.A block move operation moves a block; e.g., block transposition, suffix block transposition etc.A small sample of the research in this broad area follows.Christie studied sorting permutations by transpositions and proved a tighter lower bound based on the hurdles of the underlying cycle graph and designed a simpler 3/2-approximation algorithm [13].The first non-trivial lower and upper bounds for prefix transposition distance over permutations were given in [2].Chitturi et al. [14] shows how to compute the transposition distances of all permutations in S n in an amortized time of O(n 3 ).Recently, subsets of permutations related to a certain type of block move operation have been counted [15].These results are varied in type that employ distinct techniques such as dynamic programming and applications of graph properties, and constructs such as cycle graphs and adjacencies in permutations.
A Cayley graph Γ T under the operation T over S n is defined as follows.The vertex set V of Γ T consists of all permutations in S n .There is an edge from vertex u to vertex v if there is a generator g ∈ T such that ug = v.The distance between two permutations α, and β under the operation T, d T (α, β) is equal to the number of edges in the shortest path between the corresponding vertices in Γ T .The A transposition tree in turn gives rise to a Cayley graph (refer Figure 1).The problem of sorting permutations using transposition trees is also known as token swapping on trees [5,6,11,[16][17][18][19].Given a tree T consisting of n vertices {v 1 , v 2 , . . .v n } and edge set E, a configuration of T is an assignment of n distinct markers or tokens {1, 2 . . .n} to the vertices of T. Tokens can be moved along the tree edges only.Given an initial configuration f i and a target configuration f t of a tree T, token swapping problem is to transform T from f i to f t with minimum number of moves.
An optimal algorithm for sorting permutations using path requires k moves where k is the number of inversions in the given permutation [20].The reverse permutation (n, n − 1, n − 2 . . . 1) is the diametral permutation of S n that requires n(n − 1)/2 moves to sort.Another transposition tree studied in the past is star.A star (with center, say v 1 ) is a transposition tree with vertex set {v 1 , v 2 . . .v n } and edge set {(v 1 , v 2 ), (v 1 , v 3 ) . . .(v 1 , v n )}.Efficient optimal algorithms for sorting permutations using a star are known [1,21,22].The optimum number of moves required to sort permutations using star is m + c, where m is the number of un-homed leaf markers, and c is the number of permutation cycles of length ≥ 2, in the given permutation, consisting of un-homed leaf markers only [5].When all cycles in a given permutation are of length 2, it takes the maximum number of moves to sort that permutation.Thus, the diameter of star graph is 3/2(n − 1) [1].
Generic algorithms to compute upper bounds (not necessarily tight) for sorting permutations with any given transposition tree have been studied.Akers and Krishnamurthy [1] propose the first known such algorithm that require exponential running time.Ganesan [23] proposed a method to compute an upper bound β max in exponential time which is an estimate of the upper bound by analyzing the structure of the transposition tree.Chitturi [24] designed two polynomial (O(n 2 )) time algorithms, γ and δ for computing upper bounds.The cumulative sum of upper bound values of γ and δ for all trees of a particular size were found to be tighter than the values provided by earlier methods.Furthermore, these algorithms solely analyzed the structure of the tree and were computationally efficient.Kraft [25] proposed randomized algorithms with polynomial running time which were looser than the other upper bounds.Uthan and Chitturi define a class of trees called S m,k [26] and prove an exact upper bound for the same.

Sorting Permutations with a Single Broom
In this section, we design a polynomial time optimal algorithm for sorting permutations using a single broom.A single broom is a tree obtained by joining the center vertex of a star with one of the two leaf vertices of a path graph, using a new edge.A single broom has n vertices, partitioned into two sets called star vertices v 1 , v 2 , . . ., v k , and path vertices v k+1 , . . . ,v n , where 2 ≤ k ≤ (n − 3).Note that the center of the star, i.e., v k+1 is also a path node.Similarly, markers are partitioned into two sets called star markers and path markers.A star marker is a marker whose home is a star node, and a path marker is a marker whose home is a path node.A new efficient optimal algorithm called A b , for sorting permutations using single broom is given in Section 3.1.

Algorithm A b
Let S min be the star marker that is closest to its home residing on the path and P max be the largest path marker that is not homed.Our algorithm A b for single broom that transforms a given input configuration to a sorted configuration, consists of the following 3 steps in the given order.
Efficiently home the markers in the star that need to be homed.
An illustration of algorithm A b for a single broom is given in Figure 2. In the initial setup, we have two unhomed star markers on path, i.e., 3 on v 7 and 2 on v 8 .S min is 3 in the first iteration and in the next it will be 2. Homing markers 3 and 2 take 5 swaps in total.Then, there will be no star markers residing on the path.Thus, we can start with Step 2 of our algorithm.P max is 8 and a swap with 7 homes both the markers.Only the star markers 5 and 4 at v 4 and v 5 respectively need to be homed.Our algorithm homes all markers in total of 9 swaps, exactly the same number of swaps that are taken by the algorithms of Biniaz et al. [5], Yamanaka et al. [6] and Vaughan [10].Step 1 and Step 2 of A b have the following properties: 1.
Star markers residing on the path always move to the left in the increasing order of their distances from their respective homes; 2.
A path marker moves right to its home; thereby moving the smaller path markers towards the center; 3.
Swap involving two star markers will not take place on a path edge.
The next section covers the analysis and correctness proof of the algorithm A b .

Analysis of A b
We begin our analysis for the number of swaps with Step 1.Let D(S p ) be the distance from S p to its home, where S p are the star markers residing on the path of the broom.S p , can reside either on the central node or on the rest of the nodes in the path.Note that homing a marker from central node to a star leaf takes exactly a single swap.W s is the total number of swaps executed in Step 1. Since, we home the nearest markers first, the distances of the markers that are homed subsequently do not increase.Thus, we have the following expression.
Observe that for Step 2, we are now left only with the path containing path markers.The total moves required on the path to place the markers at their desirable vertices is same as the number of inversions [9,27,28].Let D(P p ) be the distance from the path marker P p to its home, where P p is the path marker residing on the path of the broom.W p is the total number of swaps executed in Step 2.Then, for the reason stated for W s in Step 1, For the final step in A b , let L S be the number of permutation cycles not containing the center vertex that have a length ≥ 2 and N S be the number of markers in these cycles.These markers are not swapped in Step 1 or Step 2. So, as discussed before in Section 2, the number of swaps to home the star markers is L S + N S .
W b , the total number of swaps performed in A b is : Step 1 of A b takes a distance-based approach in which S min is selected on the basis of its distance from the leaf nodes in the star.Step 2 obeys a value-based approach in which a maximum valued path marker is homed first.Biniaz's, Kawahara's and Vaughan's algorithms are strictly based on a value-based approach and work in O(n 2 ) time. Figure 3 compares the traversal of markers in A b with the algorithms proposed by Biniaz and Kawahara.
Time complexity of A b can be expressed in terms of number of moves.The total number of S min markers possible in Step 1 is min(S, P) where S is the number of star vertices and P is the number of path vertices.The worst case of this step occurs when all the path nodes are occupied by star markers and the homes of these star markers are occupied by other star markers.The total number of moves required in Step 1 is (P(P + 1)/2) + (S − P).The worst case of Step 2 occurs when all P path markers need to be homed with a total swap count of P(P − 1)/2.Solving the star in step 3 requires a maximum of 3S/2 moves.Since As the number of edges in a single broom is n − 1, the tree requires O(n) space, and the algorithm does not require any additional space.Algorithm A b Biniaz's Algorithm Kawahara's Algorithm

Correctness of A b
In this section, we prove that A b finds an optimal swap sequence, S opt , which always follows some interesting properties.To show that, S opt is optimal, we first prove that these properties hold for a given marker on a broom and then apply induction on n.Lemma 1.An optimal path sequence S opt will obey following properties: A pair of markers swap at most once.

Proof.
We prove it using contradiction.Suppose the swap sequence S = S 1 , S 2 , S 3 . . .S s , contains the swap of (x, y) twice at S i and S j .Modify S by deleting S i and S j .Then, for each swap S k where i < k < j, replace x with y and vice-versa.Resulting swap sequence is shorter and achieves the same results.

2.
Star markers that enter the star from path do so in the increasing order of their distance from center.

Proof.
Consider two star markers x and y residing on the path.Assume x and y are at a distance d and d + c respectively from their home.Let S be the swap sequence containing the swap S i which swaps y and x on the path.Marker y will be homed after a swap with the marker residing on its home H y , call this swap S j where j > i. Similarly x will be homed after a final swap S k with H x where k > j.Call this intermediate configuration of markers as S .We show how S can be modified in order to obtain an optimal sequence.To modify S, omit S i and carry out further swaps with x & y and H x & H y exchanged, until the swap S k .Observe that we have obtained the same marker configuration as in S but with fewer swaps.

3.
Two star markers will never swap on a path edge.

Proof.
Let us take x and y to be the star markers that swap on the path edge in S. We show how S can be modified to obtain a swap sequence with a lesser number of swaps on the path.After the swap of x and y in S, at some point of time, both x and y will get into the star.Let S be a sub sequence of S, where y resides on a star leaf and x on the center node.To modify S, remove the swap of x and y and replace x with y and vice versa for the following swaps.Iterate this till the point S is reached in S and add a swap of x and y.We have achieved the same target state, but a swap carried out on the path is removed and compensated by adding an additional swap in the star.
In every swap on the path edge involving at least one path marker, the larger of the markers will move to the right.

Proof.
Considering the contradiction of the stated property, a bad swap involves moving a smaller valued path marker to the right and larger valued path marker to the left.Suppose S contains a bad swap.We show how S can be modified to obtain a new swap sequence which contains fewer swaps on the path.Assume smaller marker s is swapped to the right and larger marker l to the left.Property 1 restricts us from directly swapping them again.Therefore, marker l will move to the star leaf, then marker s to another star leaf and then l goes to the center of the star.Let us call this intermediate placement as S .Now, to modify S, remove the swap of s and l, and continue with the preceding swaps with s and l exchanged until the state S is reached.We have achieved the same target state, but a swap carried out on the path is removed and compensated for by adding an additional swap in the star; hence, reducing the swap count on the path edge.

5.
No star marker moves past the first path edge from left to right.

Proof.
Let S include a swap S i in which a maker x moves past the first path edge to the right using a swap with a marker p. Let, S j is a swap belonging to S where j > i which results in x reentering the star with the help of a swap with q.Taking the least possible j into account, we first establish that the marker q was residing on the star leaf during S i .Suppose q was on path node during S i , then q will lie on the right to x. Swaps involving x between S i and S j will only keep it on path nodes and not move it past the first path edge as per our assumption.Marker q is restricted to swap twice with x on the path edge as per Property 1, which proves that q lies on the right of x during S j , which is contradictory.We show how S can be modified to obtain a swap sequence with a lesser number of swaps on the path.Before S i , carry out a swap of x and q and continue with the following swaps till S j − 1 with x replaced with y and vice-versa.We have achieved the same target state but the swap on a path edge is removed and replaced by a swap on a star edge, hence reducing the number of swaps on the path edge.
Theorem 1. Algorithm A b computes an optimal swap sequence, i.e., a sorting sequence with the least possible number of swaps.
Proof.We prove that our algorithm obtains an optimal swap sequence by applying induction on marker n.The base case is just a star S. Depending on the position of S min and P max , we consider different cases and prove them individually.Moreover, for the general induction step, we prove that swaps performed by S min and P max are a part of an optimal swap sequence.
Case (1): The initial position of S min is any path vertex other than the center vertex.Let S opt be the optimal swap sequence.Property 2 and Property 3 ensures that n will never encounter a star marker on the path and hence it will only swap path markers on its way home.Let d be the distance from the initial position of marker n to its home vertex H n .So, S opt contains d swaps which involves marker n.Let S i be the swap that homes marker n, therefore S 1 , S 2 , . . ., S i contain d swaps which includes marker n and (i − d) swaps that do not include marker n.Call this intermediate configuration T. Create a separate swap sequence S opt which homes n in first d swaps followed by i − d swaps that do not involve n and then carry on with rest of the swaps from S i+1 , . . ., S k .Homing marker n does not alter the relative order of the remaining markers.Clearly, we have attained the same configuration state as in T, implying S opt is an optimal swap sequence which is generated by our algorithm A b .
Consider S be an optimal swap sequence which brings n to the center vertex.Observe that n can be placed on center in exactly d − 1 swaps, where d is the distance of n from its home vertex H n on the star leaf.Let S c be the swap in S = S 1 , S 2 , . . ., S c that places marker n on the center and T be the intermediate configuration of the markers after S c .Create a swap sequence S that homes the marker n first in d − 1 swaps and carries out the rest of the c − (k − 1) swaps, which does not include n.Clearly, you will get the same resulting configuration as of T with the same number of swaps.Hence, S is an optimal swap sequence.Now, call S h the swap that homes n from the center vertex by swapping it with an arbitrary marker t residing on H n .Aforementioned discussion assumes that no swaps which involve star edges occur before S h .Otherwise, when n is initially placed on the center vertex or arrives at the center with the swap S c , it suffices to show that S opt is optimal which does not alter the position of n before the swap S h .We do some modifications in S opt to make this true.Split the subsequence S 1 , S 2 , . . ., S h−1 into S path and S star , where the subsequence S path contains the swaps that occur on path edges and the subsequence S star contains the swaps that occur on star edges.Note that S path does not move marker n from its position and S star always places n back to the center.We can rearrange this subsequence containing S star and S path as there are no star markers moving towards the path and vice versa as mentioned in Property 5.After S path , carry out the swap S h and then perform the swaps in S star but with t and n exchanged.This results in the same placement of markers with no change in the swap count on the star and path.Hence, S opt is same as the optimal sequence generated by our algorithm A b .Case (2): After Step 1 of A b , it is important to observe that we are now only left with path markers as all the star markers are either homed or residing on star nodes (will be homed in Step 3).So, lets consider marker n = P max is on a path vertex, except the center vertex.According to the property proved before, P max will always move to the right, swapping the lesser value marker to the left.Let S be the swap sequence which contains swap moves for homing P max .Consider S h to be the swap which slots P max in its home and T be the configuration at that instance.Considering distance d between P max and its home, we can say S 1 . . .S h will have d swaps involving P max and (i − d) not involving P max (say S be that swap sequence).To modify S, we first make d swap moves which involve P max , followed by S and then S i+1 . . .S f inal , call this swap sequence S o .It is interesting to observe that initial d swap moves will not change the relative order of the rest of the path markers, post which, S swap moves can be performed, ultimately resulting in the same configuration T; hence S o is optimal.Now, suppose n = P max is on the center vertex.Let S p be the swap that marker n on the first path edge e = (v k+1 , v k+2 ) with an arbitrary marker t.If we assume there are no swaps before S p , we can just prove it with the above mentioned discussion in Case 2. Else, it suffices to show that S opt is optimal and does not alter the position of n before S p .We modify S opt to make this true.Split the subsequence S 1 , S 2 , . . ., S p−1 into S path and S star , where S path contains the swaps that occur on path edges and S star contains the swaps that occur on star edges.Note that S path does not move marker n from its position and S star always places n back to the center.Additionally, as per Property 5 we can rearrange the subsequence containing S star and S path as there are no star markers moving towards the path and vice versa .To rearrange this subsequence, perform the swaps in S path , then the swap S p followed by the swaps in S star .While performing the saps in S star replace the marker n with marker t.This results in same placement of markers with no change in the swap count on the star and path edges; hence, S opt is optimal and is the same as the one generated by our algorithm A b .
Case (3): As discussed before, for Step 3 the optimal number of swaps are L S + N S where L S be the number of permutations that have a length ≥ 2 not involving the center vertex (say V c ) and N S be the number of markers that are in these permutations.In case of star, consider a sequence P of length ≥ 2 and the star vertices (say V s ).If V c / ∈ P, then the total swap count to sort P is V s + 1.If V c ∈ P, then the total swap count is V s .As the cycles in L S are not related to each other, L S + N S gives the optimal swap count.

Sorting Permutations with a Double Broom
A novel polynomial algorithm A db is designed in this section for optimally sorting permutations using a double broom.A double broom is a double star with their central vertices joined with a path (also known as a stem) [24].Suppose double broom has a total of n vertices, v 1 , v 2 , . . ., v i on the left star, v i+1 , . . ., v j residing on the path (or stem) and v j+1 , . . ., v n on the right star.Note that we consider the central vertices v i+1 and v j of the stars as path vertices of the double broom.
Let S L and S R be the left and right stars respectively, with corresponding center vertices C L and C R .Let S R min and S L min be the closest star marker residing on the path to S R and S L respectively and P max be the maximum valued unhomed path marker.
Our algorithm A db , that transforms a given input configuration to a sorted configuration, is as follows: 1.
While ∃ a S R min marker, efficiently home S R min ; 2.
While ∃ a S L min marker, efficiently home S L min ; 3.
(At this point, only the stem is left) While ∃ a P max marker, efficiently home P max ; 4.
Efficiently home the markers of S R and S L .
Note that any vertex to the right of C L (inclusive) will be considered as a path vertex from the perspective of a marker residing in S L .Similarly, any marker to the left of C R (including) will be a path vertex for markers in S R .
Our algorithm places each marker at its respective vertex in 10 swaps (refer Figure 5).It is also noteworthy to mention that the happy leaves are swapped in the process, hence abiding to the Happy Leaves conjecture.A db obeys following interesting properties which we use to analyse the algorithm in the next section.

1.
Swap of two star markers belonging to a same star will never take place on a path edge; 2.
Stem marker moves right to its home, swapping smaller markers to the left.

Analysis of A db
Let T db be the total number of swaps performed in A db .We first consider step 4 of our algorithm.For S L , let C S L NT be the non trivial cycles and n S S L be the number of markers in these cycles.Similarly, for S R , let C S R NT be the non trivial cycles and n S R S be the number of markers in these cycles.As these markers retain their relative positions till Step 4 of our algorithm, our total number of swaps T S R ,S L in Step 4 will be: Let T R and T L be the total number of swaps carried out in Step 1 and Step 2 respectively.To analyse T R and T L , we allocate each of its swaps to closest star marker residing on the path and involved in the swap.Then, where T(S R min ) is the number of swaps allocated to closest star marker S R min .For S R min , define D(S R min ) to be the distance from a star leaf to S R min 's home.With reference to the initial configuration state of the markers, let R(S R min ) be the number of markers smaller than S R min and on the right of S R min .
Similarly, for S L min , define D(S L min ) to be the distance from a star leaf to S L min 's home and let L(S R min ) be the number of markers greater than S L min and on the right of S L min .

Claim 1. T(S R min
) is the minimum of D(S R min ) and R(S R min ).
Proof.If T(S R min ) or S L min are at star leaf of S L or S R respectively in the current configuration of markers, we can say T(S R min , where D(S L min ) ≤ L(S L min ) and thus validating our claims.

Claim 2. T(S L min
) is the minimum of D(S L min ) and L(S L min ).
Proof.If S R min is not at a star leaf of S L , we can say R(S R min ) < D(S L min ).Similarly, in case of S L min , L(S L min ) < D(S L min ), justifying the above mentioned claims.

Claim 3.
In algorithm A db , swapping Steps 1 and 2 does not alter the swap count.
Proof.In the initial configuration, let S L→R and S P→R to be the number of star markers residing in S L and on the path, respectively, whose homes are in S R .Similarly, let S R→L and S P→L be the number of star markers residing in S R and on the path respectively whose homes are in S L .Path markers can be in S L , S R , or on the path.Let the total swaps required for homing path markers be P = P P + P R + P L , where P P , P R , and let P L be the swap count for homing markers residing on the path, S R and S L respectively.Case (1): Perform Step 1 of A db followed by Step 2. Moving S R min towards the right, shifts the markers it encounters on the way to the left.This shift decreases S R→L and S P→L .Path markers entering into S L (say P L ) during a swap increase P and the number of path tokens leaving S R , i.e., P R will result in the decrease of P.
In Step 2, S L min can encounter only path markers on the way home.S L min shifts both P L markers which entered into S L in Step 1 and P L markers to the right.
(T L − (S R→L + k)) + ((P + P L − P R ) − (P L + P L )). ( At this point, we are now left only with P P as all the path markers are now residing on the path, for which the swap count will be the total number of inversions. Case (2): Perform Step 2 of A db followed by Step 1. Moving S L min towards the left, shifts the markers it encounters on the way to the right.This shift decreases S L→R and S P→R .Path markers entering into S R (say P R ) during a swap increase P and the number of path tokens leaving S L i.e., P L will result in the decrease of P.
T L + (T R − (S L→R + k)) + (P + P R − P L ), where 0 ≤ k ≤ S P→L . (3) In Step 2, S R min can encounter only path markers on the way home.S R min shifts both P R markers which entered into S R in Step 1 and P R markers to the left.
At this point, we are now left only with P P , the same as what we arrived at in Case 1.
Markers traversing towards S R in Step 1 of A db shift all the markers whose home is in S L to the left.Similarly, markers traversing towards S L shift all markers to the right; hence, there are no bad swaps and the properties of A db are obeyed.
In Step 3, observe that we are now left only with the stem markers.The total number of swaps on path are the same as the number of inversions required to place the markers at their desirable vertex.Let D(P max ) be the distance from the marker P max to its home.Similarly, we can say: where T P max are the total number of swaps in Step 3 and P max are the markers residing on the stem of the broom.

Lemma 2.
T db = T S R ,S L + T(S R min ) + T(S L min ) + ∑ P max D(P max ).
Similar to algorithm A b , time complexity of A db is also expressed in terms of the number of moves.The worst case of Step 1 occurs when all path vertices are occupied by star markers of S R and the homes of these star markers are occupied by other S R markers.The total number of moves required in this case is (P(P + 1)/2) + (S L−>R ) * (P + 1) + (S 1 − P), where S 1 and P are the number of vertices in S R and path respectively.The worst case of Step 2 occurs when all the path vertices are occupied by star markers of S L and the homes of these star markers are occupied by other S L markers.The total number of moves required in this case is (P(P + 1)/2) + (S 2 − P), where S 2 is the number of vertices in S L .In the worst case of Step 3, P(P − 1)/2 moves are required to home the P path markers.Step 4 requires 3S 1 /2 + 3S 2 /2 moves at most.Since P, S ∈ O(n), Algorithm A db runs in O(n 2 ) time.The tree requires O(n) space, and the algorithm does not require any additional space.

Correctness of A db
In this section, we prove that our algorithm A db generates an optimal swap sequence on a double broom.Initially, we discuss some properties required to prove the correctness of our algorithm.Section 1 covers the proof for properties 1 to 5.

1.
Two same markers will not swap more than once; 2.
Star markers belonging to the respective star enter into the star in the increasing order of their distances from that star; 3.
Star markers belonging to the respective star never swap with each other on the path edges.Note that the star marker belonging to S L treats the edges of the S R as path edges and vice-versa; 4.
Swaps on the stem involving at least one stem marker-the larger of the markers will move to the right' 5.
No star marker residing on one if its star vertices moves past the first path edge; 6.
In a swap s = (l, r) where l ∈ S L and r ∈ S R , l always moves to the left and r to the right.
Proof.We prove it by contradiction.A badswap involves moving l to the right and r to the left.Suppose S has a badswap on the path.We show how S can be modified to obtain a new swap sequence which contains fewer swaps on the path.Property 1 restricts us from directly swapping them again.Therefore, marker r will move to the star leaf of S L (or l will move to the star leaf of S R ), then marker l to another star leaf of S L (or r will move to another star leaf of S R ) and then l goes to the center of S l (or r will move to the center of S R ).Let us call this intermediate placement of markers S .To modify S, omit the swap of l and r, and carry on with the preceding swaps with l and r exchanged until the state S is reached.This results in the same swap count, though a swap on star replaces a swap on path.
Theorem 2. Algorithm A db generates an optimal swap sequence, i.e., a sorting sequence with the least possible number of swaps.
Proof.We prove that our algorithm obtains an optimal swap sequence by applying induction on marker n.For the base case, the double broom has no path edges and it is only a star (either S R or S L ).It is interesting to note that, this algorithm A db is equivalent to writing: 1.
While ∃ a S R min marker, home S R min .
Solve S R As discussed in the previous section, A b obtains an optimal solution and we are now left to prove only in case of S R min .Depending on the position of S R min , we consider different cases and prove them individually.In the general induction step, we prove that swaps performed by S R min are part of the optimal swap sequence.Case (1): Assume marker n = S R min is initially placed on a stem vertex, except the center node of S R .Let P opt be the optimal swap sequence.Property 2 and Property 3 ensures that n will never swap with a star marker on its way home in S R .Let d be the distance from the position of marker n to its home H n .So, there are exactly d swaps in P opt which contain marker n.Let S i be the swap that homes marker n, therefore S 1 , S 2 , . . ., S i contain d swaps which includes marker n and (i − d) swaps that do not include marker n.Let this intermediate configuration be T. Create a separate swap sequence P opt which takes the initial d swaps to homes n, followed by i − d swaps that do not involve n and then carry on with rest of the swaps from S i+1 , . . ., S k .Initial d swaps leave the remaining markers in the same relative order.We have attained the same configuration state as in T implying the swap sequence P opt is optimal and is same as the one generated by our algorithm A db .
Case (2): Consider S be an optimal swap sequence which brings n to the center vertex.Observe that n can be placed on center in exactly d − 1 swaps, where d is the distance of n from its home vertex H n on the star leaf.Let S c be the swap in S = S 1 , S 2 , . . ., S c that places marker n on the center and T be the intermediate configuration of the markers after S c .Create a swap sequence S that homes n first in d − 1 swaps and carries out the rest of the c − (k − 1) swaps which does not include n.Clearly, you will get the same resulting configuration as of T with the same number of swaps.Hence, S is an optimal swap sequence.Now, call S h the swap that homes n from the center vertex of S R by swapping it with an arbitrary marker t residing on H n .Previous discussion assumes that no swaps occur on the star edges before S h .Otherwise, when n is initially placed on the center vertex or arrives at the center with the swap S c it suffices to show that S opt is optimal and does not alter the position of n before the swap S h .We do some modifications in S opt to make this true.Split the subsequence S 1 , S 2 , . . ., S h−1 into two subsequences S path and S star .S path contains the swaps that occurs on path edges and S star contains the swaps that occurs on star edges.Note that S path does not move marker n from its position and S star always places n back to the center.We can rearrange this subsequence containing S star and S path as no star markers move towards the path and vice versa, due to the aforementioned Property 5.After S path , carry out the swap S h and then perform the swaps in S star but with t in place of n.Note that we can use the same argument for n placed on S L and prove the optimality of the subsequence as in Case 1.Clearly, this gives the same placement of markers with same swap count on the star and path.Hence, S opt is optimal and is same as the sequence generated by our algorithm A db .
Case (3): Assume n = S R min is on the leaf vertex of S L .Let t be the marker on the center vertex and S h be the swap involving n and t.If there are no swaps before S h , then just perform S h and use the argument from Case 2 to prove the optimality of the sequence P opt .Otherwise, suppose there exists a cyclic permutation P s of length L s − 1 for the markers residing in S L .Cycles which do not include n are not taken into consideration, as solving those cycles will not alter the position of n.Similar to the argument used for star, we prove that the P s can be solved in L s swaps.Each marker in C is far away by two swaps from its home, so the total distance is 2(L s − 1).However, as one swap helps us move two markers near to their respective homes, our requirement is only L s − 1 swaps.Interestingly, the initial and the final swap of P s moves only one marker which belongs to P s .Adding the swap of n and t results in a total of L s + 1 swaps contradictory to L s − 1 swaps to sort P s .

Analysis of Algorithm D* on Millipede Tree
The first known upper bound f (Γ), for sorting permutations using transposition trees, was computed by Akers and Krishnamurthy [1] in 1989.The time complexity for calculating f (Γ) is Ω(n!n 2 ), since it performs pair wise distance computation of each of the possible n! permutations.Subsequently, various polynomial time approximation algorithms were designed [23][24][25]29,30].Chitturi introduced algorithm D in [24] which finds the upper bound δ in polynomial time, which is the tightest known upper bound when the upper bounds of all trees are summed together.Subsequently, algorithm D * which identifies corresponding the upper bound δ * was designed in [29].It was shown that δ * is tighter for balanced-starburst tree [29].In [31], an analysis of both D and D * was performed and shows that δ * is tighter for full binary tree too.In this section we define a class of trees called millipede tree for which δ * is tighter, compared to δ .
A millipede tree M k is obtained by connecting the centre vertices c 1 , c 2 , . . .c k of k path graphs p 1 , p 2 , . . .p k arranged in the order, such that k is odd and the number of vertices in p i is given by the following function: The diameter of M k is (k + 1) and the total number of vertices is the center of the tree.The center has an eccentricity of (k + 1)/2.
We call the subtree above the vertex v c the upper millipede tree and the subtree below v c the lower millipede tree(refer figure 6).

Algorithm D *
Throughout this section, we employ the terminology used in [1,24,29].The eccentricity of a node u in V T , denoted by ecc(u), is equal to the maximum value of the distance between u and any other node v ∈ V T .The Center of a tree is a node with minimum eccentricity.The Diameter of T denoted as diam(T) is the maximum among all the eccentricities.The set of vertices in V T with maximum eccentricity is defined as S. S is a subset of the leaf nodes.Algorithm D deletes a set of leaf nodes L ⊂ V T , and calculates the upper bound required to home markers destined to the vertices in L. This process is continued till the graph becomes a star.The exact upper bound for a star is defined in [1], which is 3 Let X be any one of the k clusters.When the vertices of S \ X are deleted, then the diameter of the resultant tree decreases by one.The maximum distance a marker need to travel to be homed is the diameter of the tree, diam(T).Thus, D deletes all the vertices of S, except the largest cluster C * , so that minimum number of markers are homed at the current diameter and then reduces the diameter by one.Since the markers homed to the leaves are not required to move further, algorithm D deletes such leaves from the tree.Two variants of D , named D v1 and D v2 were introduced.

Analysis and Results
It is observed that D * would yield a tighter upper bound than D for a millipede tree.In the first iteration of D * on M k , the set S contains all the leaf nodes and results in two clusters-C 1 and C 2 .C 1 and C 4 are of same size which contain the leaf nodes in the upper and lower millipede trees respectively (refer Figure 7).The terminal nodes in the path graph p (k+1)/2 are not part of any cluster.Note that, deleting C 1 or C 2 will result in isomorphic trees (refer Figure 8).Since the size of the largest cluster C * (C 1 or C 2 ) is less than half of the size of S, only |C * | markers need to be homed in diam(T) cost and the remaining markers in the set S can be homed at a cost of (diam(T) − 1/2).This results in two steps x 1 and x 2 for calculating the total cost in the iteration: In the case of D , there is only one step and all the markers of C are homed in diam(T) cost.Two nodes are homed in Step x 2 resulting in an improvement of 1 in δ * .As D * and D delete all the vertices of S \ C * , the resultant tree after the first iteration is same for both.Similarly, every odd iteration generate two clusters and result in an improvement of 1.The second iteration generates two clusters C 1 and C 2 , which contain the leaf nodes of the upper and lower millipede trees respectively.Even iterations do not result in any improvement in δ * , as both the algorithms remove |C| nodes in diam(T) cost.Refer Table 1  The upper bound value for all millipede trees with diameters up to 16 was computed for both D and D * .The results (refer Table 2) show that, δ * is smaller than δ .δ * and δ are deterministic for a millipede tree since the choice of vertices for deletion in each iteration does not alter the upper bound.δ − δ * = (d/2) − 1 establishes the fact that δ * is tighter on a millipede tree as the difference is directly proportional to the initial diameter d.In terms of the number of path graphs k in the tree M k , δ − δ * can also be written as k/2 .Theorem 3. δ − δ * = Ω(k) for a millipede tree M k .

Scope for Future Research
An n-Broom (where n ≥ 3) is a transposition tree where the terminal node of the paths of n single brooms are connected to a common node.Figure 9 shows one of the possible 4-Brooms.Figures 10 and 11 show two different possible swap sequences for a 3-Broom, where brooms B 1 , B 2 and B 3 are connected to the common node V 3 .Assume that all the star markers are homed, and only the path markers are left to be homed.The figures do not show the star markers, since these markers need not be swapped while homing the path markers.Figures 10 and 11 n-Broom impacts the total swap count.Homing the path markers in B 3 before the path markers in B 1 (Figure 11) resulted in a non-optimal swap sequence which required more swaps than the swaps executed in Figure 10.Hence, A db does not guarantee an optimal swap sequence for an n-broom.Thus, designing a polynomial time optimal algorithm for sorting permutations on n-brooms is open.

Conclusions
Sorting permutations using various operations has applications in computer interconnection networks and evolutionary biology.We designed a simpler O(n 2 ) time algorithm for sorting permutations using the transposition tree single broom.We designed a novel O(n 2 ) time algorithm for optimally sorting permutations with a double broom and proved its correctness.
We defined a new class of trees that we call millipede.Among the existing generic algorithms that sort with any given transposition tree, δ * and δ are the tightest and are comparable to one another.We showed that δ * yields a tighter upper bound than δ for a balanced millipede tree.
We also demonstrated how algorithm A db does not yield an optimal swap sequence in the case of n-Broom, concluding that a polynomial-time algorithm for n-broom can be a subject of future research.

Figure 1 .
Figure 1.A Transposition tree T and the corresponding Cayley graph Γ T .
D v1 removes the entire set S if |C| > 2 3 |S| and D v2 removes S if |C| ≥ 2 3 |S|, where C = S \ C * .D * , which calculates the upper bound δ * [29] is an improved version of D .If |S \ C * | > |C * |, then at most |C * | markers need diam(T) moves each to be homed.Algorithm D * works based on this idea.The proof can be seen in [29,31].D * deletes |C * | nodes in diam(T) cost and the remaining nodes in the cluster with (diam(T) − 1/2) cost.It is observed that the δ * is tighter than δ when |C * | is between one-third and half of the total size of set |S|.
, where D C(C * ) is the cost per node for homing |C * | nodes in Algorithm D , D C(S − C * ) is the cost per node for homing |S \ C * | nodes in Algorithm D , D * C(C * ) is the cost per node for homing |C * | nodes in Algorithm D * and D * C(S − C * ) is the cost per node for homing |S \ C * | nodes in Algorithm D * .After (k − 1) iterations in M k , the tree becomes a star, which is the base case of both the algorithms.As mentioned above, D * C o = D C o − 1 where D C o is the cost computed in D and D * C o is the cost computed in D * , for every odd iteration.Therefore after the ith iteration, the total improvement is (i + 1)/2 .

Figure 9 .
Figure 9. n-Broom with n = 4 and v 22 as the connecting node.

Table 2 .
Comparison of δ and δ * on millipede trees with various diameters.