Enumerating permutations sortable by k passes through a pop-stack - - PowerPoint PPT Presentation

enumerating permutations sortable by k passes through a
SMART_READER_LITE
LIVE PREVIEW

Enumerating permutations sortable by k passes through a pop-stack - - PowerPoint PPT Presentation

Enumerating permutations sortable by k passes through a pop-stack Anders Claesson Bjarki gst Gumundsson University of Iceland 1 / 20 Theorem (Knuth, 1968) 3124 A permutation is sortable by a stack if and only if avoids 231 .


slide-1
SLIDE 1

Enumerating permutations sortable by k passes through a pop-stack

Anders Claesson Bjarki Ágúst Guðmundsson University of Iceland

1 / 20

slide-2
SLIDE 2

Theorem (Knuth, 1968)

A permutation π is sortable by a stack if and only if π avoids 231.

Theorem (Avis & Newborn, 1981)

A permutation π is sortable by a pop-stack if and only if π avoids 231 and 321.

3124 3124

2 / 20

slide-3
SLIDE 3

Theorem (Knuth, 1968)

A permutation π is sortable by a stack if and only if π avoids 231.

Theorem (Avis & Newborn, 1981)

A permutation π is sortable by a pop-stack if and only if π avoids 231 and 321.

124 3 124 3

2 / 20

slide-4
SLIDE 4

Theorem (Knuth, 1968)

A permutation π is sortable by a stack if and only if π avoids 231.

Theorem (Avis & Newborn, 1981)

A permutation π is sortable by a pop-stack if and only if π avoids 231 and 321.

24 3 1 24 3 1

2 / 20

slide-5
SLIDE 5

Theorem (Knuth, 1968)

A permutation π is sortable by a stack if and only if π avoids 231.

Theorem (Avis & Newborn, 1981)

A permutation π is sortable by a pop-stack if and only if π avoids 231 and 321.

24 3 1 24 13

2 / 20

slide-6
SLIDE 6

Theorem (Knuth, 1968)

A permutation π is sortable by a stack if and only if π avoids 231.

Theorem (Avis & Newborn, 1981)

A permutation π is sortable by a pop-stack if and only if π avoids 231 and 321.

4 3 2 1 4 2 13

2 / 20

slide-7
SLIDE 7

Theorem (Knuth, 1968)

A permutation π is sortable by a stack if and only if π avoids 231.

Theorem (Avis & Newborn, 1981)

A permutation π is sortable by a pop-stack if and only if π avoids 231 and 321.

4 3 12 4 132

2 / 20

slide-8
SLIDE 8

Theorem (Knuth, 1968)

A permutation π is sortable by a stack if and only if π avoids 231.

Theorem (Avis & Newborn, 1981)

A permutation π is sortable by a pop-stack if and only if π avoids 231 and 321.

4 123 4 132

2 / 20

slide-9
SLIDE 9

Theorem (Knuth, 1968)

A permutation π is sortable by a stack if and only if π avoids 231.

Theorem (Avis & Newborn, 1981)

A permutation π is sortable by a pop-stack if and only if π avoids 231 and 321.

4 123 1324

2 / 20

slide-10
SLIDE 10

Theorem (Knuth, 1968)

A permutation π is sortable by a stack if and only if π avoids 231.

Theorem (Avis & Newborn, 1981)

A permutation π is sortable by a pop-stack if and only if π avoids 231 and 321.

1234 1324

2 / 20

slide-11
SLIDE 11

Theorem (Knuth, 1968)

A permutation π is sortable by a stack if and only if π avoids 231.

Theorem (Avis & Newborn, 1981)

A permutation π is sortable by a pop-stack if and only if π avoids 231 and 321.

Theorem (Pudwell & Smith, 2017)

A permutation π is sortable by two passes through a pop-stack if and only if π avoids 2341, 3412, 3421, 4123, 4231, 4312, 4¯ 1352 and 413¯ 52.

1234 1324

2 / 20

slide-12
SLIDE 12

Theorem (Knuth, 1968)

A permutation π is sortable by a stack if and only if π avoids 231.

Theorem (Avis & Newborn, 1981)

A permutation π is sortable by a pop-stack if and only if π avoids 231 and 321.

Theorem (Pudwell & Smith, 2017)

A permutation π is sortable by two passes through a pop-stack if and only if π avoids 2341, 3412, 3421, 4123, 4231, 4312, 4¯ 1352 and 413¯ 52. 1 − √ 1 − 4x 2x x − 1 2x − 1 x3 + x2 + x − 1 2x3 + x2 + 2x − 1

2 / 20

slide-13
SLIDE 13

Stacks vs pop-stacks

A stack is a LIFO data structure with two operations:

◮ Push: Add an element to the top of the stack. ◮ Pop: Remove the top-most element from the stack.

A pop-stack is a LIFO data structure with two operations:

◮ Push: Add an element to the top of the stack. ◮ Pop: Remove all elements from the stack.

We’ll insist that elements on the stack are increasing when read from top to bottom and sort greedily w.r.t. the push operation.

3 / 20

slide-14
SLIDE 14

How many permutations are sortable by k passes through a pop-stack?

k = 1 x − 1 2x − 1 k = 2 x3 + x2 + x − 1 2x3 + x2 + 2x − 1 k ≥ 3 Rational?

4 / 20

slide-15
SLIDE 15

5 1 2 4 7 8 6 3 9

5 / 20

slide-16
SLIDE 16

5 1 2 4 7 8 6 3 9

5 / 20

slide-17
SLIDE 17

5 1 2 4 7 8 6 3 9

5 / 20

slide-18
SLIDE 18

5 1 2 4 7 8 6 3 9 1 5

5 / 20

slide-19
SLIDE 19

5 1 2 4 7 8 6 3 9 1 5

5 / 20

slide-20
SLIDE 20

5 1 2 4 7 8 6 3 9 1 5 2

5 / 20

slide-21
SLIDE 21

5 1 2 4 7 8 6 3 9 1 5 2

5 / 20

slide-22
SLIDE 22

5 1 2 4 7 8 6 3 9 1 5 2 4

5 / 20

slide-23
SLIDE 23

5 1 2 4 7 8 6 3 9 1 5 2 4

5 / 20

slide-24
SLIDE 24

5 1 2 4 7 8 6 3 9 1 5 2 4 7

5 / 20

slide-25
SLIDE 25

5 1 2 4 7 8 6 3 9 1 5 2 4 7

5 / 20

slide-26
SLIDE 26

5 1 2 4 7 8 6 3 9 1 5 2 4 7

5 / 20

slide-27
SLIDE 27

5 1 2 4 7 8 6 3 9 1 5 2 4 7

5 / 20

slide-28
SLIDE 28

5 1 2 4 7 8 6 3 9 1 5 2 4 7 3 6 8

5 / 20

slide-29
SLIDE 29

5 1 2 4 7 8 6 3 9 1 5 2 4 7 3 6 8

5 / 20

slide-30
SLIDE 30

5 1 2 4 7 8 6 3 9 1 5 2 4 7 3 6 8 9

5 / 20

slide-31
SLIDE 31

5 1 2 4 7 8 6 3 9 1 5 2 4 7 3 6 8 9

5 / 20

slide-32
SLIDE 32

5 1 2 4 7 8 6 3 9 1 5 2 4 7 3 6 8 9 1

5 / 20

slide-33
SLIDE 33

5 1 2 4 7 8 6 3 9 1 5 2 4 7 3 6 8 9 1

5 / 20

slide-34
SLIDE 34

5 1 2 4 7 8 6 3 9 1 5 2 4 7 3 6 8 9 1

5 / 20

slide-35
SLIDE 35

5 1 2 4 7 8 6 3 9 1 5 2 4 7 3 6 8 9 1 2 5

5 / 20

slide-36
SLIDE 36

5 1 2 4 7 8 6 3 9 1 5 2 4 7 3 6 8 9 1 2 5

5 / 20

slide-37
SLIDE 37

5 1 2 4 7 8 6 3 9 1 5 2 4 7 3 6 8 9 1 2 5 4

5 / 20

slide-38
SLIDE 38

5 1 2 4 7 8 6 3 9 1 5 2 4 7 3 6 8 9 1 2 5 4

5 / 20

slide-39
SLIDE 39

5 1 2 4 7 8 6 3 9 1 5 2 4 7 3 6 8 9 1 2 5 4

5 / 20

slide-40
SLIDE 40

5 1 2 4 7 8 6 3 9 1 5 2 4 7 3 6 8 9 1 2 5 4 3 7

5 / 20

slide-41
SLIDE 41

5 1 2 4 7 8 6 3 9 1 5 2 4 7 3 6 8 9 1 2 5 4 3 7

5 / 20

slide-42
SLIDE 42

5 1 2 4 7 8 6 3 9 1 5 2 4 7 3 6 8 9 1 2 5 4 3 7 6

5 / 20

slide-43
SLIDE 43

5 1 2 4 7 8 6 3 9 1 5 2 4 7 3 6 8 9 1 2 5 4 3 7 6

5 / 20

slide-44
SLIDE 44

5 1 2 4 7 8 6 3 9 1 5 2 4 7 3 6 8 9 1 2 5 4 3 7 6 8

5 / 20

slide-45
SLIDE 45

5 1 2 4 7 8 6 3 9 1 5 2 4 7 3 6 8 9 1 2 5 4 3 7 6 8

5 / 20

slide-46
SLIDE 46

5 1 2 4 7 8 6 3 9 1 5 2 4 7 3 6 8 9 1 2 5 4 3 7 6 8 9

5 / 20

slide-47
SLIDE 47

5 1 2 4 7 8 6 3 9 1 5 2 4 7 3 6 8 9 1 2 5 4 3 7 6 8 9

5 / 20

slide-48
SLIDE 48

5 1 2 4 7 8 6 3 9 1 5 2 4 7 3 6 8 9 1 2 5 4 3 7 6 8 9 1

5 / 20

slide-49
SLIDE 49

5 1 2 4 7 8 6 3 9 1 5 2 4 7 3 6 8 9 1 2 5 4 3 7 6 8 9 1

5 / 20

slide-50
SLIDE 50

5 1 2 4 7 8 6 3 9 1 5 2 4 7 3 6 8 9 1 2 5 4 3 7 6 8 9 1 2

5 / 20

slide-51
SLIDE 51

5 1 2 4 7 8 6 3 9 1 5 2 4 7 3 6 8 9 1 2 5 4 3 7 6 8 9 1 2

5 / 20

slide-52
SLIDE 52

5 1 2 4 7 8 6 3 9 1 5 2 4 7 3 6 8 9 1 2 5 4 3 7 6 8 9 1 2

5 / 20

slide-53
SLIDE 53

5 1 2 4 7 8 6 3 9 1 5 2 4 7 3 6 8 9 1 2 5 4 3 7 6 8 9 1 2

5 / 20

slide-54
SLIDE 54

5 1 2 4 7 8 6 3 9 1 5 2 4 7 3 6 8 9 1 2 5 4 3 7 6 8 9 1 2 3 4 5

5 / 20

slide-55
SLIDE 55

5 1 2 4 7 8 6 3 9 1 5 2 4 7 3 6 8 9 1 2 5 4 3 7 6 8 9 1 2 3 4 5

5 / 20

slide-56
SLIDE 56

5 1 2 4 7 8 6 3 9 1 5 2 4 7 3 6 8 9 1 2 5 4 3 7 6 8 9 1 2 3 4 5

5 / 20

slide-57
SLIDE 57

5 1 2 4 7 8 6 3 9 1 5 2 4 7 3 6 8 9 1 2 5 4 3 7 6 8 9 1 2 3 4 5 6 7

5 / 20

slide-58
SLIDE 58

5 1 2 4 7 8 6 3 9 1 5 2 4 7 3 6 8 9 1 2 5 4 3 7 6 8 9 1 2 3 4 5 6 7

5 / 20

slide-59
SLIDE 59

5 1 2 4 7 8 6 3 9 1 5 2 4 7 3 6 8 9 1 2 5 4 3 7 6 8 9 1 2 3 4 5 6 7 8

5 / 20

slide-60
SLIDE 60

5 1 2 4 7 8 6 3 9 1 5 2 4 7 3 6 8 9 1 2 5 4 3 7 6 8 9 1 2 3 4 5 6 7 8

5 / 20

slide-61
SLIDE 61

5 1 2 4 7 8 6 3 9 1 5 2 4 7 3 6 8 9 1 2 5 4 3 7 6 8 9 1 2 3 4 5 6 7 8 9

5 / 20

slide-62
SLIDE 62

5 1 2 4 7 8 6 3 9 1 5 2 4 7 3 6 8 9 1 2 5 4 3 7 6 8 9 1 2 3 4 5 6 7 8 9

◮ A sorting trace of length 9 and order 3. ◮ Numbers within a block are in decreasing order. ◮ Adjacent numbers in different blocks form an ascent. ◮ Each perm is the “blockwise reversal” of the one above. ◮ The last permutation is the identity.

5 / 20

slide-63
SLIDE 63

7 5 2 4 9 1 8 6 3 2 5 7 4 1 9 3 6 8 2 5 1 4 7 3 9 6 8 2 1 5 4 3 7 6 9 8 1 2 3 4 5 6 7 8 9

A sorting trace Its sorting plan a d d a a d a d d a a a a d d a d a a a a a d a a d a d a a a d a d d a d a d a The same sorting plan 0, 9, 10, 5, 5, 10, 5, 10, 9, 0 . . . and its encoding

6 / 20

slide-64
SLIDE 64

7 5 2 4 9 1 8 6 3 2 5 7 4 1 9 3 6 8 2 5 1 4 7 3 9 6 8 2 1 5 4 3 7 6 9 8 1 2 3 4 5 6 7 8 9

A sorting trace Its sorting plan 0 1 1 0 0 1 0 1 1 0 0 0 0 1 1 0 1 0 0 0 0 0 1 0 0 1 0 1 0 0 0 1 0 1 1 0 1 0 1 0 The same sorting plan 0, 9, 10, 5, 5, 10, 5, 10, 9, 0 . . . and its encoding

6 / 20

slide-65
SLIDE 65

Basic bijections

k-pop-stack-sortable permutations sorting traces sorting plans sort using pop-stack drop numbers append id, then blockwise rev. take topmost permutation Bijection between k-pop-stack-sortable permutations of [n] and sorting plans of length n and order k

7 / 20

slide-66
SLIDE 66

An operation array of length 9 and order 3:

8 / 20

slide-67
SLIDE 67

An operation array of length 9 and order 3:

◮ Assume there is a sorting trace with this operation array.

8 / 20

slide-68
SLIDE 68

An operation array of length 9 and order 3: 1 2 3 4 5 6 7 8 9

◮ Assume there is a sorting trace with this operation array. ◮ The last permutation must be the identity.

8 / 20

slide-69
SLIDE 69

An operation array of length 9 and order 3: 1 2 3 4 5 6 7 8 9 2 1 4 3 7 6 5 8 9

◮ Assume there is a sorting trace with this operation array. ◮ The last permutation must be the identity. ◮ Each perm is the “blockwise reversal” of the perm above.

8 / 20

slide-70
SLIDE 70

An operation array of length 9 and order 3: 1 2 3 4 5 6 7 8 9 2 1 4 3 7 6 5 8 9 2 3 4 1 7 6 9 8 5

◮ Assume there is a sorting trace with this operation array. ◮ The last permutation must be the identity. ◮ Each perm is the “blockwise reversal” of the perm above.

8 / 20

slide-71
SLIDE 71

An operation array of length 9 and order 3: 1 2 3 4 5 6 7 8 9 2 1 4 3 7 6 5 8 9 2 3 4 1 7 6 9 8 5 3 2 4 6 7 1 8 9 5

◮ Assume there is a sorting trace with this operation array. ◮ The last permutation must be the identity. ◮ Each perm is the “blockwise reversal” of the perm above.

8 / 20

slide-72
SLIDE 72

An operation array of length 9 and order 3: 1 2 3 4 5 6 7 8 9 2 1 4 3 7 6 5 8 9 2 3 4 1 7 6 9 8 5 3 2 4 6 7 1 8 9 5

◮ Assume there is a sorting trace with this operation array. ◮ The last permutation must be the identity. ◮ Each perm is the “blockwise reversal” of the perm above.

8 / 20

slide-73
SLIDE 73

An operation array of length 9 and order 3: 1 2 3 4 5 6 7 8 9 2 1 4 3 7 6 5 8 9 2 3 4 1 7 6 9 8 5 3 2 4 6 7 1 8 9 5

◮ Assume there is a sorting trace with this operation array. ◮ The last permutation must be the identity. ◮ Each perm is the “blockwise reversal” of the perm above.

8 / 20

slide-74
SLIDE 74

An operation array of length 9 and order 3: 1 2 3 4 5 6 7 8 9 2 1 4 3 7 6 5 8 9 2 3 4 1 7 6 9 8 5 3 2 4 6 7 1 8 9 5

◮ Assume there is a sorting trace with this operation array. ◮ The last permutation must be the identity. ◮ Each perm is the “blockwise reversal” of the perm above. ◮ This semitrace is not a (proper) trace, so the operation

array is not a sorting plan!

8 / 20

slide-75
SLIDE 75

1 2 3 4 5 6 7 8 1 3 2 5 4 6 7 8 3 1 5 2 4 7 6 8 3 5 1 7 4 2 6 8 5 3 7 1 4 2 8 6 7 3 5 1 6 8 2 4

An example semitrace

1 2 3 4 5 6 7 8 1 3 2 5 4 6 7 8 3 1 5 2 4 7 6 8 3 5 1 7 4 2 6 8 5 3 7 1 4 2 8 6 7 3 5 1 6 8 2 4

The progress of 2 and 4 A forbidden segment

a b a b a b b a b a a b

Following a and b

9 / 20

slide-76
SLIDE 76

Lemma

In a sorting plan, each but the first row has blocks of size ≤ 3.

Proof

2 1

  • 2

3 2 1

  • 3

2 4 3 2 1

X

10 / 20

slide-77
SLIDE 77

Lemma

If T is a forbidden segment in some semitrace of order k, then |T| ≤ 4k − 5.

Proof

b a b a b a b a

1 2 3 4 1 2 3 4

Corollary

For a fixed k, there are finitely many forbidden segments of

  • rder k, and they can be listed.

11 / 20

slide-78
SLIDE 78

◮ For k = 1 there are no forbidden segments. ◮ For k = 2 the forbidden segments are

1 ∅ 2    ,    3

  • 12 / 20
slide-79
SLIDE 79

7 5 2 4 9 1 8 6 3 2 5 7 4 1 9 3 6 8 2 5 1 4 7 3 9 6 8 2 1 5 4 3 7 6 9 8 1 2 3 4 5 6 7 8 9

A sorting trace Its sorting plan a d d a a d a d d a a a a d d a d a a a a a d a a d a d a a a d a d d a d a d a The same sorting plan 0, 9, 10, 5, 5, 10, 5, 10, 9, 0 . . . and its encoding

13 / 20

slide-80
SLIDE 80

7 5 2 4 9 1 8 6 3 2 5 7 4 1 9 3 6 8 2 5 1 4 7 3 9 6 8 2 1 5 4 3 7 6 9 8 1 2 3 4 5 6 7 8 9

A sorting trace Its sorting plan 0 1 1 0 0 1 0 1 1 0 0 0 0 1 1 0 1 0 0 0 0 0 1 0 0 1 0 1 0 0 0 1 0 1 1 0 1 0 1 0 The same sorting plan 0, 9, 10, 5, 5, 10, 5, 10, 9, 0 . . . and its encoding

13 / 20

slide-81
SLIDE 81

◮ Encode an operation array of length n and order k as a

sequence of n integers, each in the range Γ = {0, 1, . . . , 2k − 1}.

◮ Thus operation arrays can be seen as strings in Γ ∗. ◮ A DFA for the language of operation arrays, W, is

start Σ

14 / 20

slide-82
SLIDE 82

◮ Let Ai be the set of symbols in Σ that represent a column

that has a bar in the ith row

◮ The following DFA, Ri, recognizes the operation arrays that

have blocks of size at most 3 in row i: start Ai Ai Ai Σ Ai Ai Ai

◮ Operation arrays that have blocks of size at most 3 in all

but the first row is thus recognized by the DFA W ∩ R2 ∩ · · · ∩ Rk.

15 / 20

slide-83
SLIDE 83

◮ Recall that sorting plans are characterized by avoiding

forbidden segments.

◮ Let us encode a segment M in the same manner as we

encode operation arrays, resulting in the sequence m1, . . . , mℓ.

◮ An operation array A contains the segment M if and only if

the encoding of A contains m1 · · · mℓ as a factor.

◮ The following NFA, QM, recognizes strings over Σ that

contain the encoding of M as a factor: start

. . .

m1 m2 mℓ−1 mℓ Σ Σ

16 / 20

slide-84
SLIDE 84

Let F be the set of forbidden segments. Then S = W ∩

k

  • i=2

Ri ∩

  • F∈F

QF recognizes the set of sorting plans.

Theorem

The language S = { w ∈ Σ∗ : w is a sorting plan } is regular.

17 / 20

slide-85
SLIDE 85

Main result

◮ Let pk(n) be the number of k-pop-stack-sortable

permutations of [n].

◮ Let Pk(x) =

  • n≥0

pk(n)xn.

Theorem

The generating function Pk(x) is rational.

18 / 20

slide-86
SLIDE 86

Data

This has been implemented. Running on a big cluster we got: k 1 2 3 4 5 6 degree 1 3 10 25 71 213 growth rate 2.0000 2.6590 3.4465 4.2706 5.1166 5.9669 vertices 4 5 12 32 99 339 edges 8 11 34 120 477 2010 All the generating functions, source code, and text files defining the DFAs can be found on GitHub: github.com/SuprDewd/popstacks

19 / 20

slide-87
SLIDE 87

Generating functions

1 (x − 1) / (2x − 1) 2 (x3 + x2 + x − 1) / (2x3 + x2 + 2x − 1) 3 (2x10 + 4x9 + 2x8 + 5x7 + 11x6 + 8x5 + 6x4 + 6x3 + 2x2 + x − 1) / (4x10+8x9+4x8+10x7+22x6+16x5+8x4+6x3+2x2+2x−1) 4 (64x25 + 448x24 + 1184x23 + 1784x22 + 2028x21 + 1948x20 + 1080x19+104x18−180x17+540x16+1156x15+696x14+252x13+ 238x12+188x11+502x10+806x9+544x8+263x7+185x6+99x5+ 33x4+13x3+3x2+x−1) / (128x25+896x24+2368x23+3568x22+ 3928x21 + 3064x20 + 176x19 − 2304x18 − 2664x17 − 1580x16 − 352x15−576x14−1104x13−760x12−138x11+686x10+1238x9+ 869x8 + 382x7 + 210x6 + 102x5 + 27x4 + 12x3 + 3x2 + 2x − 1) 5, 6 too large to display

20 / 20