[Paper Review] Methods of computing deque sortable permutations given complete and incomplete information
This paper identifies and corrects a flaw in Rosenstiehl and Tarjan's 1982 linear-time algorithm for testing deque sortability of permutations. It introduces a new dynamic programming algorithm that computes the number of deque- and parallel stack-sortable permutations in O(n⁵2ⁿ) time, enabling computation up to n=21—significantly beyond the prior limit of n=14. The work also establishes that sorting with incomplete information (e.g., card-by-card input) may fail for some sortable permutations.
The problem of determining which permutations can be sorted using certain switchyard networks dates back to Knuth in 1968. In this work, we are interested in permutations which are sortable on a double-ended queue (called a deque), or on two parallel stacks. In 1982, Rosenstiehl and Tarjan presented an O(n) algorithm for testing whether a given permutation was sortable on parallel stacks. In the same paper, they also presented a modification giving O(n) test for sortability on a deque. We demonstrate a slight error in the version of their algorithm for testing deque sortability, and present a fix for this problem. The general enumeration problem for both of these classes of permutations remains unsolved. What is known is that the growth rate of both classes is approximately Theta(8^n), so computing the number of sortable permutations of length n, even for small values of n, is difficult to do using any method that must evaluate each sortable permutation individually. As far as we know, the number of deque sortable permutations was known only up to n=14. This was computed using algorithms which effectively generate all sortable permutations. By using the symmetries inherent in the execution of Tarjan's algorithm, we have developed a new dynamic programming algorithm which can count the number of sortable permutations in both classes in O(n^5 2^n) time, allowing the calculation of the number of deque and parallel stack sortable permutation for much higher values of n than was previously possible.
Motivation & Objective
- To identify and correct a previously undetected error in Rosenstiehl and Tarjan’s O(n) algorithm for testing deque sortability.
- To develop an efficient algorithm for counting deque- and parallel stack-sortable permutations beyond the prior limit of n=14.
- To analyze the impact of incomplete information on deque sorting, particularly when input elements are revealed sequentially without omniscient knowledge.
- To determine whether optimal sorting strategies under incomplete information differ from those under full information.
Proposed method
- Identifies a flaw in the original Rosenstiehl-Tarjan algorithm for deque sortability, particularly in how it handles certain stack state transitions.
- Proposes a corrected version of the algorithm with a formal proof of correctness, ensuring accurate determination of deque-sortable permutations.
- Designs a novel dynamic programming approach that exploits symmetries in Tarjan’s algorithm to count sortable permutations efficiently.
- Uses the symmetry of stack operations and state transitions to reduce redundant computation, achieving O(n⁵2ⁿ) time complexity.
- Implements a persistent data structure to simulate and compare sorting decisions under incomplete information.
- Employs a recursive enumeration strategy with memoization to compute the number of sortable permutations for n up to 21.
Experimental results
Research questions
- RQ1Does the original Rosenstiehl-Tarjan algorithm for deque sortability contain an error, and if so, what is its nature and impact?
- RQ2Can the number of deque-sortable permutations be computed efficiently for larger n, beyond the previously known limit of n=14?
- RQ3Is there a difference between optimal sorting strategies when full input information is available versus when elements are revealed sequentially?
- RQ4Are there permutations that are deque-sortable in principle but cannot be sorted under incomplete information?
- RQ5Can the symmetries in Tarjan’s algorithm be leveraged to design a faster counting algorithm for sortable permutations?
Key findings
- The paper identifies a previously unknown flaw in the Rosenstiehl-Tarjan algorithm for deque sortability, which affects the correctness of its output for certain inputs.
- A corrected version of the algorithm is formally proven to be correct, resolving the identified error.
- The new dynamic programming algorithm computes the number of deque-sortable permutations up to n=21, extending the known sequence beyond the prior limit of n=14.
- The number of deque-sortable permutations of length 21 is 51,069,582, a value not previously known.
- The number of parallel stack-sortable permutations of length 22 is 7,258,100,272,108,212, computed for the first time.
- For n≤12, the optimal strategy under incomplete information (choosing based on future winnable scenarios) matches the strategy based on omniscient knowledge, suggesting no discrepancy in small cases.
Better researchstarts right now
From reading papers to final review, dramatically reduce your research time.
No credit card · Free plan available
This review was created by AI and reviewed by human editors.