 
Summary: Sorting with two ordered stacks in series
M. D. Atkinson a; M. M. Murphy b N. Ruskuc b
a Department of Computer Science, University of Otago, Dunedin, New Zealand
b School of Mathematics and Statistics, University of St Andrews, St Andrews
KY16 9SS
Abstract
The permutations that can be sorted by two stacks in series are considered, subject
to the condition that each stack remains ordered. A forbidden characterisation of
such permutations is obtained and the number of permutations of each length is
determined by a generating function.
Key words: Stacks, permutations, forbidden patterns, enumeration
1 Introduction
The question of which permutations can be sorted by a single stack, and
how many there are of each length, was solved by Knuth in [5]. He showed
that a permutation is stack sortable if and only if it has no subpermutation
231 (i.e. subsequence order isomorphic to 231) and that the number of such
permutations of length n is the n th Catalan number. At the same time he
also introduced the problem of sorting permutations by two or more stacks in
series and this was subsequently investigated further by Tarjan in [10].
Let S k denote the set of permutations that can be sorted by k stacks in series.
