TOPICS
Search

Stack-Sortable Permutation


A stack-sortable permutation is a permutation sorted into increasing order by a single application of the deterministic stack-sorting map s. This map reads entries from left to right, pushes the next entry onto a stack if the stack is empty or that entry is smaller than the top entry, and otherwise pops the top entry into the output. After the input is exhausted, it pops the remaining entries. More generally, a t-stack-sortable permutation is sorted by at most t applications of s. For example, s(3142)=1324 and s(1324)=1234, so 3142 is 2-stack-sortable.

The stack-sortable permutations are exactly those avoiding the permutation pattern 231, and their number in the symmetric group S_n is the Catalan number C_n. The number of 2-stack-sortable permutations in the symmetric group S_n is

 2/((n+1)(2n+1))(3n; n).

Inagaki and Luo (2026) proved that the number of 2-stack-sortable permutations of {0,1,...,n} ending in 0 is the Motzkin number M_n for every n>=0.


See also

Catalan Number, Motzkin Number, Permutation, Permutation Pattern

Explore with Wolfram|Alpha

References

Inagaki, R. and Luo, M. "Motzkin Numbers Count 2-Stack-Sortable Permutations Ending in Their Least Entry." 2 Oct 2026. https://arxiv.org/abs/2610.02756.

Cite this as:

Weisstein, Eric W. "Stack-Sortable Permutation." From MathWorld--A Wolfram Resource. https://mathworld.wolfram.com/Stack-SortablePermutation.html

Subject classifications