Extremal permutations in routing cycles

Let $G$ be a graph on $n$ vertices, labeled $v_1,\ldots,v_n$ and $\pi$ be a permutation on $[n]:=\{1,2,\cdots, n\}$. Suppose that each pebble $p_i$ is placed at vertex $v_{\pi(i)}$ and has destination $v_i$. During each step, a disjoint set of edges is selected and the pebbles on each edge are swapped. Let $rt(G, \pi)$, the routing number for $\pi$, be the minimum number of steps necessary for the pebbles to reach their destinations. Li, Lu, and Yang prove that $rt(C_n, \pi)\le n-1$ for any permutation on $n$-cycle $C_n$ and conjecture that for $n \geq 5$, if $rt(C_n, \pi) = n-1$, then $\pi = (123\cdots n)$ or its inverse. By a computer search, they show that the conjecture holds for $n<8$. We prove in this paper that the conjecture holds for all even $n$.


Introduction
Routing problems occur in many areas of computer science. Sorting a list involves routing each element to the proper location. Communication across a network involves routing messages through appropriate intermediaries. Message passing between multiprocessors requires the routing of signals to correct processors.
We wish to move pebbles to their destinations. To do so, at each round we select a matching of G and swap the pebbles at the endpoints of each edge, and repeat rounds until all pebbles are in place.
Let rt(G, π) denote the minimum number of rounds necessary to route π on G. Then, the routing number of G is defined as: Note that when each matching in the routing process consists of one edge, the routing number corresponds to the diameter of Cayley graph generated by (cyclically) adjacent transpositions. The diameter problem of Cayley graphs has a rich research literature, and we refer the reader to the book [3] for a comprehensive survey.
Very few results are known for the exact values of the routing numbers of graphs.
Zhang [6] improved the above bound on trees, showing that rt(T n ) ≤ 3n 2 + O(log n). Li, Lu, and Yang [5] showed that n + 1 ≤ rt(Q n ) ≤ 2n − 2, improving both the previous upper and lower bounds on hypercubes. Among other results, they showed that rt(C n ) = n − 1, and made the following conjecture.
The conjecture does not hold for n = 4; the permutation that transposes two non-adjacent vertices and fixes the other two serves as a counterexample. They verified the conjecture for n < 8 through a computer search. The conjecture is kind of counter-intuitive: the permutations on the cycle requiring most time to route are the ones that each pebble is very close to (actually at distance one from) its destination.
In this article, we give a proof of the conjecture when n is even.
Some new tools are introduced in the proof, beyond the ideas from [1] by Albert, Li, Strang, and the last author. These tools, introduced in Section 2, enable us to describe precisely the swapping process of each pebble, and determine the pebbles that need n − 1 steps to route, see Section 3 for detail. In Section 4, we show that the only permutations that need n − 1 steps to route must be the two permutations in the theorem.

Important notion and tools
Let G = C n with even n ≥ 6 and label the vertices of C n as 1, 2, . . . , n in the clockwise order. Let the clockwise direction be the positive direction and counter clockwise be the negative direction. In the rest of the paper, when list pebbles or sets of pebbles in a row, we always think them to be in the clockwise order on the cycle.
2.1. The Odd-Even Routing Algorithm. An odd-even sort or odd-even transposition sort is a classic sorting algorithm (see [4]) used to sort a list of numbers on parallel processors. To describe this algorithm, we may place the n numbers to be sorted on the vertices of the path P n = v 1 v 2 . . . v n . An edge e = v i v i+1 is odd if and only if i is odd. At each odd step (respectively, even step) of the routing process, we select a matching consisting of odd edges (respectively, even edges) whose two numbers have the wrong order and swap the numbers on the endpoints.
We apply a similar algorithm on even cycles, whose edges can be partitioned into two perfect matchings. We shall call edges in one perfect matching to be even and the others to be odd. Thus, once the parity of one edge is specified, the parity of all the edges is determined. During the odd steps (respectively, even steps) we choose a matching consisting of odd edges (respectively, even edges) whose two pebbles are comparable (defined in subsequent subsections). If an edge e is chosen to be an odd edge, we would call this algorithm the odd-even routing algorithm with odd edge e.

Spins and Disbursements.
There are exactly two paths for pebble p i to reach its destination, by traveling either in the positive or negative direction. Let d + (i, j) denote the distance from the vertex i to the vertex j along the positive direction. Then if i < j, then For simplicity, for pebbles p i and p j , we define d + (p i , p j ) = d + (i, j), and if p i and p j are on the endpoints of an edge, we sometimes call the edge p i p j .
Consider a routing process of a permutation π on C n with pebble set P = {p 1 , . . . , p n }. For each pebble p i , let s(p i ), the spin of p i , represent the displacement for p i to reach its destination from its current position. So, s(p i ) ∈ {d + (i, π(i)), d + (i, π(i)) − n}. Note that the spin of a pebble changes with its movement.
A sequence B = (s(p 1 ), s(p 2 ), . . . , s(p n )) is called a valid disbursement of π if the spins can be realized by a routing process on π. Not all combinations of spins give valid disbursements. The following lemma gives a necessary and sufficient condition for a set of spins to be a valid disbursement. Lemma 1. Let B = (s(p 1 ), s(p 2 ), . . . , s(p n )) be an assignment of the spins to the pebbles. It is a valid disbursement if and only if n i=1 s(p i ) = 0. Proof. To see the necessity, we observe that when two pebbles are swapped, one moves forward one step and one moves backward one step, so the sum of spins remains invariant. Since B is a valid disbursement, the final spins are all zeroes, so the sum is also zero.
For sufficiency, we can move the pebbles one by one along their assigned directions.
From this lemma, a valid disbursement of a non-identity permutation π must contain both positive and negative spins. Let s(p i ) > 0 and s(p j ) < 0 in a valid disbursement B of π. By flipping the spins of p i and p j , we change the spins of p i and p j to s(p i ) − n and s(p j ) + n, respectively. Clearly, after one flip, we obtain a new valid disbursement.
A valid disbursement (s(p 1 ), . . . , s(p n )) is minimized if p∈P |s(p)| is minimized. The following simple fact is very important.
Proof. For otherwise, one can make the sum smaller by flipping the spins of p i and p j .

2.
3. An order relation. Once a valid disbursement B = (s(p 1 ), s(p 2 ), . . . , s(p n )) of π is given, some restrictions are placed on the routing processes realizing B. For example, if s(p i ) − s(p j ) > d + (p i , p j ), then p i and p j must swap at some round in the routing processes. In other words, each valid disbursement is associated with an order relation on the pebbles. Definition 1. Let B = (s(p 1 ), s(p 2 ), . . . , s(p n )) be a valid disbursement. We call Note that the order relation is transitive. To see that, let p i ≻ p j and p j ≻ p k . Then As two pebbles have different destinations, s(p i ) − s(p j ) = d + (p i , p j ), so if p i ≻ p j is not true, then s(p i ) − s(p j ) < d + (p i , p j ). When p i ≻ p j , we say that p i and p j are comparable, or more precisely, p i is bigger than p j and p j is smaller than p i . If p i is neither bigger nor smaller than p j , we call them incomparable. If each pebble in set P 1 is bigger than every pebble in P 2 , we also write P 1 ≻ P 2 .
The following lemma provides a convenient way to determine order relations.
Lemma 3. Let x, y, z be three pebbles in the clockwise order sitting on the cycle. If x ≻ z, then x ≻ y or y ≻ z. Furthermore, if x ≻ z, then y is not smaller than z and not bigger than x.
Proof. For otherwise, s(x) − s(y) < d + (x, y) and s(y) − s(z) < d + (y, z). It follows that . Then x is not bigger than z, a contradiction.
The following lemma says that we only need to swap comparable pebbles to route the permutation.
Lemma 4. Let B be a minimized disbursement of π. If a pebble p is incomparable with all other pebbles, then s(p) = 0, i.e., the pebble p is at its destination vertex.
Let π = Π i π i be a cycle decomposition of π, where π i = (i 1 , · · · , i r i ). Then the pebble placed at i k , which we call pebble i k to save symbols, has destination i k+1 for all k ≤ r i , with i r i +1 = i 1 . Let P i be the set of pebbles on π i . We say that π i is the orbit of the pebbles in P i . We may assume that p = i 1 .
We claim that for each j, q∈P j s(q) = an for some integer a. To see this, we note that s(j k ) ∈ {d + (j k , j k+1 ), d + (j k , j k+1 ) − n}. Thus, if the spins are all positive, the sum equals bn for some positive integer b. However, each switch of a spin from positive to negative would cause a change of −n in the sum. So the sum of spins remains a multiple of n.
We further claim that all pebbles in P i have positive spins, which also implies that As the sum of all spins is zero, there exists some orbit π j with spin sum cn for some integer c < 0. In particular, there exists a pebble q ∈ P j such that q passes p = i 1 in the negative direction to arrive its destination. So s(q) + d + (p, q) < 0 < s(p) and it follows that p ≻ q, a contradiction.
Note that the order of pebbles is always associated with the current disbursement, which may not be the same as the initial disbursement. The following lemma says that whether or not two pebbles swap is determined by the initial disbursement. So we will not keep tracking of the spins, but just see whether necessary swaps are performed. Lemma 5. If p i and p j are incomparable, then in the sorting process, they will always be incomparable. If p i ≻ p j , then p i and p j are incomparable after the swap of p i and p j .
Proof. If p i and p j are incomparable, then in the sorting process, (s(p i ) − s(p j )) − d + (p i , p j ) does not change: if a pebble swaps with both p i and p j , then it must be bigger than or smaller than both p i and p j , thus the distance from p i to p j does not change and s(p i ) − s(p j ) does not change; If a pebble swaps only with p i , then s(p i ) increases by one and d + (p i , p j ) increases by one; If a pebble swaps only with p j , then s(p j ) increases by one and d + (p i , p j ) decreases by one. Now let p i ≻ p j . We only need to show that they become incomparable right after the swap of p i and p j , by what we just proved. Since Let s ′ (p i ) and s ′ (p j ) respectively be the new spins of p i and p j right after the swap of p i and p j . Note that p i and p j are adjacent to each other only if the pebbles on the segment from p i to p j along the positive direction have swapped with p i (for those smaller than p i ) or p j (for those bigger than p j ). Then thus after the swap, p i cannot be bigger than p j .
When B is minimized and two pebbles p i and p j satisfy s(p i ) − s(p j ) = n, we still get a minimized disbursement after flipping the spins of p i and p j . The following lemma tells us how the order relation changes when we do such a flip.
. For pebbles not in {p i , p j }, the spins and distance do not change from B to B ′ , so their order relation does not change as well.
(2) For k / ∈ {i, j}, we know that By Lemma 4, the routing process ends when no pebble has a bigger or smaller pebble. So we have the following equation, which is heavily used to determine the spins of the pebbles in our later proofs.
By Lemma 3, there are no u ∈ U, w ∈ W such that u, w, p 0 or p 0 , u, w on C n . So if U = {u 1 , u 2 , . . . , u r } and W = {w 1 , w 2 , . . . , w t }, then we may assume that the pebbles in U ∪ W and p 0 are ordered as u r , . . . , u 1 , p 0 , w 1 , . . . , w t on C n . We denote the set of pebbles incomparable to p 0 between p 0 and w t (between u r and p 0 resp.) by X (Y resp.).
A segment is a sequence of consecutive pebbles. An U-segment is a segment whose pebbles are all in U, and likewise, we have W -segments, X-segments and Y -segments. So we can group the pebbles between u r and w t along the positive direction as where X 1 , Y 1 may be empty, and win(p 0 ) is called the initial window of p 0 . So in the window win(p 0 ) of the pebble p 0 , from the leftmost (the U-segment) to p 0 , the segments are alternatively U-and Y -segments, and from the rightmost (the W -segment) to p 0 , the segments are alternatively W -and X-segments. We shall use this notation without further notice.
We denote the set of all other pebbles as Z. So sometimes we write π as By transitivity, we have u i ≻ w j since u i ≻ p 0 ≻ w j for all 1 ≤ i ≤ r and 1 ≤ j ≤ t, and in particular, u r ≻ w t , hence n ≥ s(u r ) − s(w t ) > d + (u r , w t ). By Lemma 3, if i ≥ j, then u ≻ y for all u ∈ U i , y ∈ Y j ; If k ≥ l, then w ≺ x for all w ∈ W k , x ∈ X l . 2.5. Two important lemmas. A nice property of the odd-even routing algorithm is the following Lemma 7. Let p be a pebble and Q be a segment of pebbles. If p ≻ Q or Q ≻ p, then once p starts to swap with a pebble in Q in an odd-even routing algorithm, p will not stop swapping until p swaps with all pebbles in Q (in the following |Q| − 1 or more steps).
Proof. By symmetry, we let p ≻ Q. An enlargement of Q is a segment obtained from Q by mixing some pebbles that are smaller than p.
We first claim that if x, y ≻ Q, then after swapping with some pebbles in Q, x and y can never be on an edge unless they have swapped with all pebbles in Q. Suppose that the first time such an edge occurs at step s. That is, after step s − 1, we have q, x, y, q ′ , where x, y ≻ {q, q ′ }. Now, at step s − 1, xq and yq ′ are among the chosen edges. So, after step s − 1, we should have q, x, q ′ , y, a contradiction.
Note that for a pebble q between p and Q along the positive direction, by Lemma 3, either p ≻ q or q ≻ Q; in the former case, q either becomes a pebble in an enlargement of Q or p, q swap before p meets a pebble in Q. So we may assume that all pebbles from p to Q along the positive direction are bigger than Q. Now by the claim, p never meets a pebble incomparable with p before it finishes swapping with Q. So p moves continuously.
Proof. By symmetry we only consider the case when q > 0. For each pebble p, the spin of p is either q or q − n. Since the sum of spins is zero, there must be exactly n − q pebbles with the positive spin and q pebbles with the negative spin. So, n − q ≤ rt(C n , π). Now, we show that rt(C n , π) ≤ n − q. Let the pebbles be p 1 , p 2 , . . . , p n on C n . We assign spins to the pebbles so that s(p 2i−1 ) = q − n for 1 ≤ i ≤ q and each of the remaining n − q pebbles has the spin q. We use an odd-even routing algorithm with odd edge p 1 p 2 . As q ≤ n/2, no two pebbles with spin q − n are adjacent. In the routing process, p 1 will be paired with p 2 , p 4 , . . . , p 2q , p 2q+1 , . . . , p n in the first n − q steps, thus reach its destination, and similar things occur for all other pebbles with negative spins. When all pebbles with negative spins reach their destinations, there is no comparable pebbles, so each pebble will be in place. Thus, π is routed in n − q steps.

Extremal Windows
Now we count the steps needed for an arbitrary pebble, say p 0 , to swap with all comparable pebbles. Let the initial window of p 0 be As we only consider how p 0 swaps with other pebbles, we ignore the swaps between pebbles inside each of the segments, and regard them to be incomprable for now. By Lemma 7, when we apply the odd-even routing algorithm, p 0 will meet a segment S ∈ {U 1 , . . . , U k , W 1 , . . . , W l } and swap with all the pebbles in S in the following |S| steps. Assume that p 0 meets the segments in the order S 1 , S 2 , . . . , S k+l , where S i ∈ {U 1 , . . . , U k , W 1 , . . . , W l }.
For i = 1, 2, ..., k + l − 1, let ω i be the waiting time between S i−1 and S i , that is, the number of steps that p 0 waits between swapping with the last pebble of S i−1 and swapping with the first pebble of S i . Let α be the largest index such that ω α = 0.
By symmetry, we assume that S α = W t . Because of the parity, a swap of p 0 and W (or p 0 and U) cannot be followed by a swap of p 0 and U (or p 0 and W ). Therefore, as ω α+1 = · · · = ω k+l = 0, ∪ i≥α S i = ∪ l i=t W i and p 0 will swap with them continuously until it reaches its destination. Let w be the pebble in W t next to X t . Since we ignore the swaps between pebbles in W , w only moves in one direction (counter-clockwise). Then the steps for p 0 to be in place are the steps for p 0 and w to meet plus | ∪ l i=t W i |. To meet p 0 , w has to swap with pebbles in ∪ t j=1 X j and ∪ k i=1 U i . We also note that, w is always paired with a comparable pebble starting from the first or the second step, depending on the parity of the first edge with which w is incident. Thus the total number of steps for p 0 to be in place is: where δ = 0 if w ∈ W t is paired with an X-pebble in the first step, and δ = 1 otherwise.
By symmetry, if S α = U t , then the number of steps for p 0 to be in place is Therefore, every permutation that takes n − 1 steps to route must contain a pebble p 0 such that (when S α = W t ) Now we are ready to determine the extreme windows that need n − 1 steps to route.
Proof. By symmetry, we may assume that (4) holds. As δ = 0 or 1, all the terms in the left-hand side of (4) are zeros or ones.
We first claim that when |win(p 0 )| = n, U k or W l must be empty. For otherwise, let u p ∈ U k and w q ∈ W l be the furthest U-pebble and W -pebble to p 0 , respectively. As |win(p 0 )| = n, no pebble is bigger than u p and no pebble is smaller than w q by Lemma 3, so s(u p ) ≥ 1 + |Y | + |W | and s(w q ) ≤ −(1 + |X| + |U|), and it follows that s(u p ) − s(w q ) ≥ n + 1, a contradiction. Case 1. δ = 0 or δ = |Z| = 1. Then k j=1 |Y j | = l j=t+1 |X j | = t−1 j=1 |W j | = 0. It follows that Y = ∅, t = 1 = l. So win(p 0 ) = (U, p 0 , X, W ). By the above claim, when |win(p 0 )| = n, U or W must be empty, so we have (i) or (ii) in the lemma, where X (or Y ) could be empty.

Proof of Theorem 2
In this section, we show how to deal with the extremal situations in Lemma 9. For each of the extreme windows, we will decompose it into blocks of the following kinds. Let q 1 , q 2 , . . . , q s be a segment of pebbles. It is called a block with head q 1 if q 1 ≻ q i for i ≥ 2 and the other pebbles are incomparable; it is called a block with tail q s if q i ≻ q s for i < s and the other pebbles are incomparable; it is called an isolated block if none of the pebbles is comparable.
We start with a minimized disbursement B of π, the permutation that cannot be routed in n − 2 steps. By Lemma 9, π should contain a pebble with one of the extreme windows. We shall determine π explicitly and alter the disbursement and/or the odd-even routing algorithm to show that it can be routed in n − 2 steps. 4.1. Extremal window type 1: win(p 0 ) = (p 0 , X, W ) and |win(p 0 )| = n.
Consider the spin of x 1 . It is clear that s(x 1 ) ≥ |W | since x 1 ≻ W and no pebble is bigger than x 1 (by Lemma 3). Then s(x 1 ) − s(w b ) ≥ n. It follows that s(x 1 ) = |W | and x 1 ≻ W is the only order relation involving x 1 . Inductively we have s(x i ) = |W | for all x i ∈ X and {p 0 } ∪ X ≻ W is the only order relation in the permutation.
So along the positive direction every pebble is |W | steps away from its destination. So π is a rotation. By Lemma 8, π must be 23 · · · n1 or its inverse.
Lemma 11. If a permutation π contains a pebble p 0 such that win(p 0 ) = (U, p 0 , X, W ) and π = ({z}, U, p 0 , X, W ),where U, W = ∅, then U and W are isolated blocks, and X can be partitioned into X 1 , . . . , X r such that X i is either an isolated block or a block with tail x i . Furthermore, s(z) = c ≤ 0, and if c < 0, then X r is an isolated block with −c pebbles, and the order relations are Proof. Let U = u 1 u 2 . . . u p , X = x 1 x 2 . . . x a and W = w 1 w 2 . . . w b . Consider the spins of u 1 and w b . As no pebble is bigger than u 1 and Similarly, no pebble is smaller than Inductively we can consider u 2 and w b−1 and all pebbles in U and W and conclude that U ∪ {p 0 } ∪ X ≻ W is the only order relation involving U and W . Now consider the spins of pebbles in X. As s(w b ) = −(1 + a + k) and s(x) − s(w b ) ≤ n for each x ∈ X, we have s(x) ≤ b + 1. Note that z cannot be bigger than any pebble in X, for otherwise z ≻ W and contradict to what we just concluded. But z may be smaller than some pebbles in X, thus s(z) ≤ 0. Consider x 1 . By Lemma 3, no pebble is bigger than x 1 . As x 1 ≻ W , s(x 1 ) ≥ |W | = b. So s(x 1 ) ∈ {b, b + 1}. Let s(x 1 ) = b + 1. Then the order relations involving x 1 are x 1 ≻ W ∪ {x i } for some 2 ≤ i ≤ a or x 1 ≻ W ∪ {z}; if x 1 ≻ z, then x j ≻ z for 1 ≤ j ≤ a by Lemma 3 and we inductively conclude s(x j ) = b + 1, thus X is an isolated block and X ≻ z; if x 1 ≻ x i for some 2 ≤ i ≤ a, then x j ≻ x i for 1 ≤ j < i by Lemma 3, and no other pebble in X is smaller than x i , for otherwise it would be smaller than x 1 which contradicts what we just concluded. So x 1 x 2 . . . x i is a block with tail x i . Now we similarly consider x i+1 and get a block partition of X. Now let s(x 1 ) = b. Then x 1 ≻ W is the only order relation involving x 1 , and we will inductively consider x 2 and get a block partition of X. Now we are ready to show that such permutations can be routed in n − 2 steps.
Proof. First we assume that X = ∅. Let π = zu 1 . . . u k p 0 x 1 . . . x a w 1 . . . w b , with u i ∈ U, x i ∈ X and w i ∈ W . We use an odd-even routing algorithm so that x a w 1 is an odd edge. The order relations are shown in Lemma 11. By Lemma 7, x a swaps with w 1 in the first step, thus swaps with W in the following |W | − 1 steps, so w b meets (i.e., is paired with a pebble in) U ∪ {p 0 } ∪ X after |W | − 1 steps, then w b would swap with U ∪ {p 0 } ∪ X in the following |U ∪ {p 0 } ∪ X| steps, so it takes |W | − 1 + |U ∪ {p 0 } ∪ X| = n − 2 steps for w b to be in place. As a pebble in U ∪ {p 0 } ∪ X has to pass W − w b to meet w b , all pebbles in W would be in place after n − 2 steps.
For z, its window win(z) = (X r , W, z), so |win(z)| = n − |U| − 1 − |X − X r | ≤ n − 2, thus, z will be in place after at most n − 2 steps, by Lemma 9. For a x j ∈ X that is in a block with tail x i , its window win( , thus x j will be in place after at most n − 2 steps, by Lemma 9.
So after n − 2 steps, there are no comparable pebbles, as each order relation involves a pebble in W ∪ {z} or a pebble in a block with a head in X. By Lemma 4, π is routed in at most n − 2 steps.
First we consider the case when k = 1 or b = 1. By symmetry, let k = 1. As n ≥ 6, b ≥ 4. Flip the spins of u and w 2 . By Lemma 4, the order relations under the new disbursement are p 0 ≻ W − w 2 , w 2 ≻ (W − w 2 ) ∪ {z, u}. We use an odd-even routing algorithm with odd edge p 0 w 1 . Then w 2 is paired with a smaller pebble in each step, thus will be in place after n − 2 steps; similarly, p 0 is paired with a smaller pebble in each of the first n − 3 steps, thus will be in place after n − 3 steps. Therefore, after n − 2 steps, there are no comparable pebbles since each order relation involves p 0 or w 2 . By Lemma 4, π is routed in n − 2 steps. Now, let k, b ≥ 2. We first flip the spins of u 1 and w b . By Lemma 6, the order relations under the new disbursement are The window for p 0 is win(p 0 ) = (U − u 1 , p 0 , W − w b ) and the window for z is win(z) = (w b , z, u 1 ), so |win(p 0 )| = n − 3 and |win(z)| = 3 ≤ n − 3 (as n ≥ 6), so by Lemma 9, p 0 and z will be in place after n − 2 steps. The window for u 1 is win(u 1 ) = (U − u 1 , W − w b + p 0 , {w b , z}, u 1 ). As b ≥ 2, it is not one of the extreme windows in Lemma 9, so u 1 will be in place in at most n − 2 steps. Now we show that all pebbles in W − w b are in place after n − 2 steps, which by Lemma 4 implies that all pebbles are in place since each order relation involves a pebble in (W − w b ) ∪ {p 0 , z, u 1 }. Note that for 1 ≤ i ≤ b−1, win(w i ) = (w b , {z, u 1 }, U −u 1 +p 0 , {w 1 , . . . , w i−1 }, w i ). Since k ≥ 2, win(u i ) is not one of the extreme windows in Lemma 9; thus, w i will be in place after n − 2 steps. 4.3. Extremal window type 2a: win(p 0 ) = (p 0 , X, W ) and |win(p 0 )| = n−1. This is the case of win(p 0 ) = (U, p 0 , X, W ) with U = ∅. In this case, W is not necessarily an isolated block. The following lemma tells the possible structures in π.
Lemma 14. If a permutation π has a pebble p 0 with win(p 0 ) = (p 0 , X, W ) and π = ({z}, p 0 , X, W ), then one of the following must be true (note that X could be empty) The proof of this lemma is very similar to Lemma 11, and for completeness, we include a proof below.
Proof. Let π = zp 0 x 1 x 2 . . . x a w 1 w 2 . . . w b , where x i ∈ X and w i ∈ W . Clearly, s(p 0 ) = |W | = b. By Lemma 3, X ≻ W . As z is incomparable with p 0 , no pebble in W is bigger than z.
Consider w b . Since {p 0 } ∪ X ≻ w b , and no pebble is smaller than w b by Lemma 3, s(w b ) ≤ −(|X| + 1) = −(a + 1). On the other hand, s(p 0 ) − s(w b ) ≤ n, for otherwise the flip of spins of p 0 and w b gives a smaller disbursement, so s(w b ) ≥ −(a + 2). Therefore s(w b ) ∈ {−(a + 1), −(a + 2)}. Clearly, if s(w b ) = −(a + 1), then {p 0 } ∪ X ≻ w b is the only order relation involving w b , thus w b is in an isolated block. We shall move to consider w b−1 . Now let s(w b ) = −(a + 2). Then exactly one pebble in {z} ∪ (W − w b ) is bigger than w b . If z ≻ w b , then by Lemma 3, z ≻ w j for each w j ∈ W − w b ; thus, inductively we conclude that the only order relation involving W is {z, p 0 } ∪ X ≻ W , and W is an isolated block.
If w i ≻ w b for some i < b, then for i < j < b, w j is not comparable with w b and w i ≻ w j by Lemma 3. Note that no pebble w l with l < i could be bigger than w i , as otherwise it would be bigger than w b which is impossible. Now inductively we conclude that w b−1 , . . . , w i+1 all have spin −(a + 2) and are only smaller than {p 0 , w i } ∪ X. That is, {w i , w i+1 , . . . , w b } is a block with head w i .
We now repeat the above argument for w b−1 (if s(w b ) = −(a + 1)) or w i−1 (if w b is in a block with head w i ), and eventually W can be partitioned into isolated blocks and/or blocks with heads. In particular, if z ≻ w r , then w r must be in an isolated block, and by Lemma 3, z ≻ {w 1 , w 2 , . . . , w r }, that is, w 1 , w 2 , . . . , w r are in an isolated block.
Note that z is not bigger than a pebble in X. For otherwise, let z ≻ x for some x ∈ X. Then z ≻ W . Thus, s(z) ≥ 1+b and s(w b ) = −(a+2), which implies that s(z)−s(w b ) ≥ n+1. Now a flip of the spins of z and w b gives a smaller disbursement, a contradiction.
• if win(p 0 ) = (p 0 , X 1 , w, X 2 , W 2 ), then X 2 can be partitioned into isolated blocks and blocks with tails. Furthermore, c := s(w) + (1 + |X 1 |) ≤ 0, and if c < 0, then the block X 0 in X 2 next to W 2 is an isolated block with −c elements and are all bigger than w; and the order relation between segments are {p 0 } ∪ X 1 ≻ {w} ∪ W 2 and X 0 ≻ w.
Proof. We only prove the case when win(p 0 ) = (p 0 , X 1 , W 1 , x, W 2 ), and the other case is very similar. Let W 1 = w 1 w 2 . . . w a and W 2 = w a+1 w 2 . . . w b . Consider the spins of p 0 and w b . Since s(p 0 ) = b and by Lemma 3, no pebble is smaller than w b , thus s(w b ) ≤ −(2 + |X|) = −(n − b); furthermore, as s(p 0 ) − s(w b ) ≤ n, we have s(w b ) ≥ −(n − b), so s(w b ) = −(n − b), and the order relation involving w b is {p 0 } ∪ X ≻ w b . Now we can repeat the argument for w b−1 , w b−2 , . . . , w a+1 successively and get s(w i ) = −(n − b) for all w i ∈ W 2 . Similarly, by comparing the spins of pebbles in X 1 to that of w b , we have s(x i ) = b for all x i ∈ X 1 . So X 1 and W 2 are isolated blocks. Since s(p 0 ) = s(x) for each x ∈ X 1 , let X ′ 1 = X 1 ∪ {p 0 }. Now we consider the spins of pebbles in W 1 . We note that no pebble in W 1 is bigger than x, for otherwise p 0 would be bigger than x as p 0 ≻ W 1 . Consider w a . The pebbles in X ′ 1 are bigger than w a and by Lemma 3, no pebble is smaller than w a , so s(w a ) ≤ −|X ′ 1 | = b − n + 1. On the other hand, s(p 0 ) − s(w a ) ≤ n and s(p 0 ) = b implies s(w a ) ≥ b − n. That is, s(w a ) ∈ {b − n, b − n + 1}, and at most one pebble other than those in X ′ 1 is bigger than w a . If s(w a ) = b − n + 1, then {p 0 } ∪ X 1 ≻ w a is the only order relation involving w a , and we turn to consider w a−1 . If s(w a ) = b − n, then w a is smaller than x or some pebble w i ∈ W 1 ; in the former case, all pebbles in W 1 are smaller than x and inductively one can show that they are incomparable and thus W 1 is an isolated block; in the latter case, w i ≻ w j for i + 1 ≤ j ≤ a and w i is the only such pebble other than those in X ′ 1 , so w i w i+1 . . . w a is a block with head w i . Inductively one can have a partition of W 1 into blocks, as desired.
We observe that if x ≻ w i ∈ W 1 , then w i is in an isolated block and x ≻ {w 1 , w 2 , . . . , w i } by Lemma 3. Let c := s(x)−|W 2 |, then W 0 := (w 1 , · · · , w c ) is an isolated block, x ≻ W 2 ∪W 0 is the only order relation involving x, as desired.
Proof. Again we only consider the case win(p 0 ) = (p 0 , X 1 , W 1 , x, W 2 ), as the other one is very similar. Let win(p 0 ) = (p 0 x 1 x 2 . . . x k w 1 . . . w a xw a+1 . . . w b ) with x i ∈ X 1 and w i ∈ W 1 ∪ W 2 . By Lemma 16, X 1 , W 2 are isolated blocks, and W 1 = ∪ r i=0 W i 1 , where x ≻ W 0 1 , and W i 1 for i > 0 is an isolated block or a block with head w i 1 . We flip the spins of p 0 and w b , and then use an odd-even routing algorithm with odd edge x k w 1 to route the permutation. Now by Lemma 6 and Lemma 16, the order relations under the new disbursement are We list the windows for the pebbles in X 1 ∪ {w b , x, w i 1 : 1 ≤ i ≤ r}: win(x i ) = (x i , X 1 − {x j : 1 ≤ j ≤ i}, W 1 , x, W 2 − w b , p 0 ), win(w i 1 ) = (w b , p 0 , X 1 , ∪ i−1 j=0 W j 1 , w i 1 , W i 1 − w i 1 ), win(x) = (x, W 2 − w b , w b , p 0 , X 1 , W 0 1 ), win(w b ) = (w b , p 0 , X 1 , W 1 , x, W 2 − w b ).