Fertility monotonicity and average complexity of the stack-sorting map

https://doi.org/10.1016/j.ejc.2020.103276Get rights and content

Abstract

Let Dn denote the average number of iterations of West’s stack-sorting map s that are needed to sort a permutation in Sn into the identity permutation 123n. We prove that 0.62433λlim infnDnnlim supnDnn35(78log2)0.87289, where λ is the Golomb–Dickman constant. Our lower bound improves upon West’s lower bound of 0.23, and our upper bound is the first improvement upon the trivial upper bound of 1. We then show that fertilities of permutations increase monotonically upon iterations of s. More precisely, we prove that |s1(σ)||s1(s(σ))| for all σSn, where equality holds if and only if σ=123n. This is the first theorem that manifests a law-of-diminishing-returns philosophy for the stack-sorting map that Bóna has proposed. Along the way, we note some connections between the stack-sorting map and the right and left weak orders on Sn.

Introduction

Motivated by a problem involving sorting railroad cars, Knuth introduced a certain “stack-sorting” machine in his book The Art of Computer Programming [22]. Knuth’s analysis of this sorting machine led to several advances in combinatorics, including the notion of a permutation pattern and the kernel method [4], [6], [21], [24]. In his 1990 Ph.D. dissertation, West defined a deterministic variant of Knuth’s machine. This variant, which is a function that we denote by s, has now received a huge amount of attention (see [5], [6], [14], [15] and the references therein). West’s original definition makes use of a stack that is allowed to hold entries from a permutation. Here, a permutation is an ordering of a finite set of integers, written in one-line notation. Let Sn denote the set of permutations of the set [n]{1,,n}. Assume we are given an input permutation π=π1πn. Throughout this procedure, if the next entry in the input permutation is smaller than the entry at the top of the stack or if the stack is empty, the next entry in the input permutation is placed at the top of the stack. Otherwise, the entry at the top of the stack is annexed to the end of the growing output permutation. This procedure stops when the output permutation has length n. We then define s(π) to be this output permutation. Fig. 1 illustrates this procedure and shows that s(4162)=1426.

There is also a simple recursive definition of the map s. First, we declare that s sends the empty permutation to itself. Given a nonempty permutation π, we can write π=LmR, where m is the largest entry in π. We then define s(π)=s(L)s(R)m. For example, s(5273614)=s(52)s(3614)7=s(2)5s(3)s(14)67=253s(1)467=2531467.

One of the central notions in the investigation of the stack-sorting map is that of a t-stack-sortable permutation, which is a permutation π such that st(π) is increasing (st is the t-fold iterate of s). Let Wt(n) be the number of t-stack-sortable permutations in Sn. The stack-sorting map moves the largest entry in a permutation to the end, so a simple inductive argument shows that every permutation of length n is (n1)-stack-sortable. It follows from Knuth’s analysis of his stack-sorting machine that the 1-stack-sortable permutations are precisely the permutations that avoid the pattern 231. Thus, W1(n) is the nth Catalan number Cn=1n+12nn. Settling a conjecture of West, Zeilberger [30] proved that W2(n)=2(n+1)(2n+1)3nn. The current author has obtained nontrivial asymptotic lower bounds for Wt(n) for every fixed t3, and he has obtained nontrivial asymptotic upper bounds for W3(n) and W4(n) [13], [15]. He has also devised a polynomial-time algorithm for computing W3(n) [15]. Instead of focusing only on t-stack-sortable permutations when t3 is small and fixed, West realized that he could make progress if he attacked from the other side. He considered the cases t=n2 and t=n3. He showed that a permutation in Sn is (n2)-stack-sortable if and only if it does not end in the suffix n1 [29]. He also characterized and enumerated (n3)-stack-sortable permutations in Sn. The case t=n4 was treated in [8].

Define the stack-sorting tree on Sn to be the rooted tree with vertex set Sn in which the root is the identity permutation 123n and in which each nonidentity permutation π is a child of s(π). The stack-sorting depth of a permutation πSn, which we denote by ssd(π), is the depth of π in this tree. Equivalently, ssd(π) is the smallest nonnegative integer t such that π is t-stack-sortable. It is natural to view s as a sorting algorithm that acts iteratively on an input permutation until reaching an increasing permutation. It requires 2n elementary operations to apply the map s to a permutation in Sn, so 2nssd(π) is the time complexity of s on the input π. We are interested in the quantity Dn=1n!πSnssd(π),which is the average depth of the stack-sorting tree on Sn. Note that 2nDn is the average time complexity of the sorting algorithm that iteratively applies s. West [29] proved that 0.23lim infnDnnlim supnDnn1,where the upper bound of 1 follows from the observation that ssd(π)n1 for all πSn. He also commented that it would probably not be possible to obtain a lower bound larger than 12 or an upper bound smaller than 1 via his pattern-avoidance approach to the problem. Our first main result is as follows.

Theorem 1.1

We have 0.62433λlim infnDnnlim supnDnn35(78log2)0.87289,where λ is the Golomb–Dickman constant.

Another crucial notion in the study of the stack-sorting map is that of the fertility of a permutation π, which is simply |s1(π)|. Many problems concerning the stack-sorting map can be phrased in terms of fertilities. For example, computing W2(n) is equivalent to finding the sum of the fertilities of all of the 231-avoiding (i.e., 1-stack-sortable) permutations in Sn. The author found methods for computing fertilities of permutations [12], [13], [15], which led to the above-mentioned advancements in the investigation of t-stack-sortable permutations when t{3,4}. Permutations with fertility 1 (called uniquely sorted permutations) possess some remarkable enumerative properties [14], [16], [25]. There is also a surprising connection between fertilities of permutations and a formula that converts from free to classical cumulants in noncommutative probability theory [11]; the author has used this connection to prove new results about the map s.

In Exercise 23 of Chapter 8 in [6], Bóna asks the reader to find the element of Sn with the largest fertility. As one might expect, the answer is 123n. The proof is not too difficult, but it is also not trivial. Our second main theorem generalizes this result by showing that the fertility statistic is strictly monotonically increasing as one moves up the stack-sorting tree.

Theorem 1.2

For every permutation σSn, we have |s1(σ)||s1(s(σ))|,where equality holds if and only if σ=123n.

Theorem 1.2 represents a step toward a law-of-diminishing-returns philosophy for the stack-sorting map that Miklós Bóna has postulated. Roughly speaking, his idea is that each successive iteration of the stack-sorting map should be less efficient in sorting permutations than the previous iterations. A concrete formulation of this idea manifests itself in Bóna’s conjecture that for each fixed n1, the sequence W1(n),W2(n),,Wn1(n) is log-concave (meaning Wt+1(n)Wt(n)Wt+2(n)Wt+1(n) for all 1tn2) [7]. Said differently, Bóna’s conjecture states that the average fertility of a (t+1)-stack-sortable permutation in Sn is at most the average fertility of a t-stack-sortable permutation in Sn. While Theorem 1.2 does not imply this conjecture, it is a step in the right direction.

Remark 1.3

Suppose π=π1πnSn, and let i[n1]. If πi>πi+1, let ti(π) be the permutation obtained from π by swapping the positions of the entries πi and πi+1. If πi<πi+1, let ti(π)=π. If i+1 appears to the left of i in π, let t˜i(π) be the permutation obtained by swapping the positions of i and i+1 in π. Otherwise, let t˜i(π)=π. The right weak order on Sn is the partial order right on Sn defined by saying that πrightπ if there exists a sequence i1,,im of elements of [n1] such that timti1(π)=π. The left weak order on Sn is the partial order left on Sn defined by saying that πleftπ if there exists a sequence i1,,im of elements of [n1] such that t˜imt˜i1(π)=π.

Theorem 1.2 is a little bit strange in view of the relationship between the stack-sorting map and these two partial orders. It is not difficult to show that for every permutation σSn, we have s(σ)rightσ. Therefore, one might expect to prove Theorem 1.2 by first establishing that |s1(π)||s1(π)| whenever πrightπ. However, this turns out to be false. We have 31425right34125, but one can show that |s1(31425)|=1<4=|s1(34125)|. On the other hand, we will be able to prove (see Theorem 3.3) that |s1(π)||s1(π)|wheneverπleftπ.Unfortunately, this inequality does not immediately imply Theorem 1.2 because the left weak order is not compatible with the action of the stack-sorting map. To see this, note that s(231)=213left231. Our proof of Theorem 1.2 will combine (1) with the Decomposition Lemma proved in [15].

Section snippets

Preliminary results

Let us begin this section with some basic terminology. The normalization of a permutation π is the permutation in Sn obtained by replacing the ith-smallest entry in π with i for all i. For example, the normalization of 4682 is 2341. We say two permutations have the same relative order if their normalizations are equal. We will tacitly use the fact, which is clear from either definition of the stack-sorting map, that s(π) and s(π) have the same relative order whenever π and π have the same

Fertility monotonicity

We now shift our focus to Theorem 1.2. In this section, it will be helpful to make use of the plot of a permutation π=π1πn, which is the diagram showing the points (i,πi)R2 for all 1in. A hook of π is a rotated L shape connecting two points (i,πi) and (j,πj) with i<j and πi<πj, as in Fig. 2. The point (i,πi) is the southwest endpoint of the hook, and (j,πj) is the northeast endpoint of the hook. Let SWi(π) be the set of hooks of π with southwest endpoint (i,πi). For example, Fig. 2 shows

Average depth

In the first part of the paper, we established improved asymptotic estimates for the average depth in the stack-sorting tree on Sn (equivalently, for the average time complexity of the algorithm that sorts via iterating s). Note, however, that it is still not known if the limit limnDnn exists. West [29] conjectured that this limit does exist; it would be exciting to have a proof of this conjecture.

We computed ssd(π) for 1000 random permutations in S400. The average of ssd(π)400 for these

Acknowledgments

The author thanks the anonymous referees for helpful comments. The author was supported by a Fannie and John Hertz Foundation Fellowship, United States of America and a National Science Foundation (United States of America) Graduate Research Fellowship (grant no. DGE-1656466).

References (30)

  • ClaessonA. et al.

    Permutations sortable by n4 passes through a stack

    Ann. Combin.

    (2010)
  • A. Claesson, B.Á. Guðmundsson, J. Pantone, Counting pop-stacked permutations in polynomial time,...
  • C. Defant, Troupes, cumulants, and stack-sorting,...
  • DefantC.

    Postorder preimages

    Discrete Math. Theor. Comput. Sci.

    (2017)
  • DefantC.

    Preimages under the stack-sorting algorithm

    Graphs Combin.

    (2017)
  • Cited by (17)

    • Troupes, cumulants, and stack-sorting

      2022, Advances in Mathematics
    • Preimages under the Queuesort algorithm

      2021, Discrete Mathematics
    • Fertilitopes

      2023, Discrete and Computational Geometry
    View all citing articles on Scopus
    View full text