taocp

This site has no text of the book. Keep your own copy of TAOCP next to it. See what is checked.

Exercise · Volume 1 · 2.2.1-13

Exercise 2.2.1-13

not stated yet in Lean solution written

RatingM48
MarkersM (mathematical)
KindK9, research: an open problem, so no proof is claimed from the written solution
SectionSection 2.2.1 of Volume 1

The task

Count the permutations of nn elements that a general deque can give, that is, a deque with inserts and removals at both ends. Call this number dnd_n.

State of the problem

No closed form or generating function for dnd_n is known. The question is open. The same count is easy for the other machines of this section. The stack gives the Catalan numbers (Exercise 2.2.1-4), and the two restricted deques give the numbers bnb_n of Exercise 2.2.1-11.

What is known

Small values. I counted dnd_n by a search over the states of the deque, one permutation at a time. The results are d1,…,d9=1, 2, 6, 24, 116, 634, 3762, 23638, 154816.d_1, \ldots, d_9 = 1,\ 2,\ 6,\ 24,\ 116,\ 634,\ 3762,\ 23638,\ 154816. The ratios dn+1/dnd_{n+1}/d_n for n=1,…,8n = 1, \ldots, 8 are 2.0002.000, 3.0003.000, 4.0004.000, 4.8334.833, 5.4665.466, 5.9345.934, 6.2836.283, 6.5496.549. They keep rising in this range, so the data alone do not show the growth rate.

The cases below n=5n = 5. Every permutation is obtained when n≤4n \le 4, and four permutations of 1234512345 fail (Exercise 2.2.1-8).

A test for one permutation. A permutation is not obtainable if and only if it contains, as a subsequence in the same relative order, a member of a family of forbidden patterns, found by Pratt. For the first member of the family, the five-element patterns are 5234152341, 5231452314, 5134251342, 5132451324. The next patterns have seven elements, and they are 52741635274163, 52741365274136, 51742635174263, 51742365174236. For n≤7n \le 7 I checked by computation that the permutations missing from the deque are exactly those that contain one of these eight patterns. For n=5,6,7n = 5, 6, 7 the missing counts are 44, 8686, 12781278.

An algorithm. Rosenstiehl and Tarjan gave a method that decides in O(n)O(n) steps whether a given permutation is obtainable. It tests one permutation. It does not count.

Closure. If a permutation is obtainable, so is each pattern inside it, by the same moves with the other cars ignored. So the set of obtainable permutations is closed under taking patterns, and dnd_n is the number of permutations that avoid an infinite set of patterns.

The exact wording is in your copy of the book.

Remarks

For a stack the avoided set has one pattern, 312312. The general deque needs an infinite set of patterns, and this is one reason why a simple count is hard to find. I make no claim about the growth rate of dnd_n.

This solution is drafted, and a person has not reviewed it yet. The source.

In Lean

not stated yet The exercise is not stated in Lean yet. The exercise is a research problem, so the project claims no proof.

The status is computed from the Lean build. The node of the map.

Something is wrong? Report it.