A Bijective Approach to the Permutational Power of a Priority Queue

Similar documents
Supplementary information Efficient Enumeration of Monocyclic Chemical Graphs with Given Path Frequencies

Math 301: The Erdős-Stone-Simonovitz Theorem and Extremal Numbers for Bipartite Graphs

Method for Approximating Irrational Numbers

The Chromatic Villainy of Complete Multipartite Graphs

New problems in universal algebraic geometry illustrated by boolean equations

The Substring Search Problem

Pushdown Automata (PDAs)

ANA BERRIZBEITIA, LUIS A. MEDINA, ALEXANDER C. MOLL, VICTOR H. MOLL, AND LAINE NOBLE

A Short Combinatorial Proof of Derangement Identity arxiv: v1 [math.co] 13 Nov Introduction

Relating Branching Program Size and. Formula Size over the Full Binary Basis. FB Informatik, LS II, Univ. Dortmund, Dortmund, Germany

9.1 The multiplicative group of a finite field. Theorem 9.1. The multiplicative group F of a finite field is cyclic.

Chapter 3: Theory of Modular Arithmetic 38

ON INDEPENDENT SETS IN PURELY ATOMIC PROBABILITY SPACES WITH GEOMETRIC DISTRIBUTION. 1. Introduction. 1 r r. r k for every set E A, E \ {0},

On the Number of Rim Hook Tableaux. Sergey Fomin* and. Nathan Lulov. Department of Mathematics. Harvard University

arxiv: v1 [math.co] 4 May 2017

10/04/18. P [P(x)] 1 negl(n).

THE JEU DE TAQUIN ON THE SHIFTED RIM HOOK TABLEAUX. Jaejin Lee

arxiv: v1 [math.nt] 12 May 2017

Solution to HW 3, Ma 1a Fall 2016

THE NUMBER OF TWO CONSECUTIVE SUCCESSES IN A HOPPE-PÓLYA URN

Syntactical content of nite approximations of partial algebras 1 Wiktor Bartol Inst. Matematyki, Uniw. Warszawski, Warszawa (Poland)

Stanford University CS259Q: Quantum Computing Handout 8 Luca Trevisan October 18, 2012

Auchmuty High School Mathematics Department Advanced Higher Notes Teacher Version

1) (A B) = A B ( ) 2) A B = A. i) A A = φ i j. ii) Additional Important Properties of Sets. De Morgan s Theorems :

When two numbers are written as the product of their prime factors, they are in factored form.

Splay Trees Handout. Last time we discussed amortized analysis of data structures

Fractional Zero Forcing via Three-color Forcing Games

Markscheme May 2017 Calculus Higher level Paper 3

ON THE INVERSE SIGNED TOTAL DOMINATION NUMBER IN GRAPHS. D.A. Mojdeh and B. Samadi

ITI Introduction to Computing II

Lecture 18: Graph Isomorphisms

Probablistically Checkable Proofs

Permutations and Combinations

3.1 Random variables

OSCILLATIONS AND GRAVITATION

Introduction Common Divisors. Discrete Mathematics Andrei Bulatov

Merging to ordered sequences. Efficient (Parallel) Sorting. Merging (cont.)

Chapter 2: Introduction to Implicit Equations

A quadratic algorithm for road coloring

Surveillance Points in High Dimensional Spaces

Matrix Colorings of P 4 -sparse Graphs

A generalization of the Bernstein polynomials

HOW TO TEACH THE FUNDAMENTALS OF INFORMATION SCIENCE, CODING, DECODING AND NUMBER SYSTEMS?

Multiple Criteria Secretary Problem: A New Approach

On a quantity that is analogous to potential and a theorem that relates to it

3.6 Applied Optimization

Graphs of Sine and Cosine Functions

Reduced Implicant Tries

On the ratio of maximum and minimum degree in maximal intersecting families

arxiv: v1 [math.co] 6 Mar 2008

An upper bound on the number of high-dimensional permutations

MATH 415, WEEK 3: Parameter-Dependence and Bifurcations

EQUI-PARTITIONING OF HIGHER-DIMENSIONAL HYPER-RECTANGULAR GRID GRAPHS

Compactly Supported Radial Basis Functions

Non-Linear Dynamics Homework Solutions Week 2

Journal of Inequalities in Pure and Applied Mathematics

Analytical Solutions for Confined Aquifers with non constant Pumping using Computer Algebra

On the Quasi-inverse of a Non-square Matrix: An Infinite Solution

ASTR415: Problem Set #6

arxiv: v1 [math.co] 1 Apr 2011

AQI: Advanced Quantum Information Lecture 2 (Module 4): Order finding and factoring algorithms February 20, 2013

Macro Theory B. The Permanent Income Hypothesis

Chapter Eight Notes N P U1C8S4-6

On the ratio of maximum and minimum degree in maximal intersecting families

Fall 2014 Randomized Algorithms Oct 8, Lecture 3

Vanishing lines in generalized Adams spectral sequences are generic

Internet Appendix for A Bayesian Approach to Real Options: The Case of Distinguishing Between Temporary and Permanent Shocks

6 PROBABILITY GENERATING FUNCTIONS

ONE-POINT CODES USING PLACES OF HIGHER DEGREE

16 Modeling a Language by a Markov Process

Semicanonical basis generators of the cluster algebra of type A (1)

ON SPARSELY SCHEMMEL TOTIENT NUMBERS. Colin Defant 1 Department of Mathematics, University of Florida, Gainesville, Florida

Functions Defined on Fuzzy Real Numbers According to Zadeh s Extension

Math Notes on Kepler s first law 1. r(t) kp(t)

SMT 2013 Team Test Solutions February 2, 2013

OLYMON. Produced by the Canadian Mathematical Society and the Department of Mathematics of the University of Toronto. Issue 9:2.

Lab 10: Newton s Second Law in Rotation

Physics 2A Chapter 10 - Moment of Inertia Fall 2018

What Form of Gravitation Ensures Weakened Kepler s Third Law?

Circular Orbits. and g =

Enumerating permutation polynomials

On decompositions of complete multipartite graphs into the union of two even cycles

EM Boundary Value Problems

SPECTRAL SEQUENCES. im(er

Research Article On Alzer and Qiu s Conjecture for Complete Elliptic Integral and Inverse Hyperbolic Tangent Function

A proof of the binomial theorem

C/CS/Phys C191 Shor s order (period) finding algorithm and factoring 11/12/14 Fall 2014 Lecture 22

QIP Course 10: Quantum Factorization Algorithm (Part 3)

Physics 211: Newton s Second Law

Goodness-of-fit for composite hypotheses.

Physics 161 Fall 2011 Extra Credit 2 Investigating Black Holes - Solutions The Following is Worth 50 Points!!!

Absorption Rate into a Small Sphere for a Diffusing Particle Confined in a Large Sphere

The Congestion of n-cube Layout on a Rectangular Grid S.L. Bezrukov J.D. Chavez y L.H. Harper z M. Rottger U.-P. Schroeder Abstract We consider the pr

Upper Bounds for Tura n Numbers. Alexander Sidorenko

Constraint Satisfaction Problems

On the integration of the equations of hydrodynamics

Suggested Solutions to Homework #4 Econ 511b (Part I), Spring 2004

The Tutte polynomial of a graph, depth-rst. search, and simplicial complex partitions

A STUDY OF HAMMING CODES AS ERROR CORRECTING CODES

NOTICE WARNING CONCERNING COPYRIGHT RESTRICTIONS: The copyright law of the United States (title 17, U.S. Code) governs the making of photocopies or

Transcription:

A Bijective Appoach to the Pemutational Powe of a Pioity Queue Ia M. Gessel Kuang-Yeh Wang Depatment of Mathematics Bandeis Univesity Waltham, MA 02254-9110 Abstact A pioity queue tansfoms an input pemutation p1 of a totally odeed set of size n into an output pemutation p2. Atkinson and Thiyagaajah showed that the numbe of such pais (p1; p2 is (n + 1 n?1, which is well known to be the numbe of labeled tees on n + 1 vetices. We give a new poof of this esult by finding a bijection fom such pais of pemutations to labeled tees. 1 Intoduction A pioity queue tansfoms an input sequence of elements of a totally odeed set into an output sequence though two opeations: Inset and Delete-Minimum. An Inset opeation takes the next element of the input sequence and places it in the pioity queue. A Delete-Minimum opeation, which can be pefomed when the pioity queue is nonempty, emoves the least element in the pioity queue and places it at the end of the output sequence. Fo a full discussion of pioity queues, see Knuth [3]. Now let us suppose that the input sequence is a pemutation of a totally odeed set S of size n. Then the output sequence is also a pemutation of S. We call (p 1 ; p 2 an allowable pai if some sequence of Inset and Delete-Minimum opeations on the input sequence p 1 yields p 2 as the output sequence. Atkinson and Thiyagaajah [1] showed that the numbe of allowable pais fo S is (n + 1 n?1. It is well known that this is also the numbe of labeled tees on a set of n + 1 vetices. (See, fo example, Knuth [2, x2.3.4.4]. In this pape we pove Atkinson and Thiyagaajah s esult by constucting a bijection fom the set of allowable pais fo S to the set of labeled tees on the set S [ fg, whee is some nonelement of S. Now let S be a totallyodeed finite set, P(S the set of all allowable pais of pemutations of S, and T (S the set of all labeled tees on S [ fg. It is convenient to oot these tees at. We shall constuct two maps S : T (S! P(S and S : P(S! T (S and then pove that S S = id P(S and S S = id T (S, which implies that S and S ae bijections. The enumeation of allowable pais then follows immediately. If the undelying set S is clea fom the context, we omit it and simply wite P, T,,, and so on. 2 Constuction of Given a ooted labeled tee T on S [ fg ooted at, we constuct a sequence of Inset and Delete-Minimum opeations on a pioity queue Q to poduce an allowable pai (T = (p 1 ; p 2. Fist, pefom depth-fist 1

2 Pemutational Powe of a Pioity Queue pocedue (T ; comment constuct an allowable pai fom a ooted labeled tee T ; begin comment initialize; p 1 := p 2 := ; Q := ;; v := ; comment v epesents whee we ae cuently in T ; while jp 2 j 6= n do begin comment n = jsj; getinput(v; while Q 6= ; and (v := deletemin has no unmaked childen do add v to the end of p 2 ; comment deletemin is the pocedue which etuns the minimum of the pioity queue Q and deletes it; Figue 1: Algoithm fo the map. seach on T, but ignoe all nodes that ae smalle than thei paents (and the descendants of such nodes. If a node has moe than one unvisited child, visit the lagest one fist. Each time we visit a node, inset it into Q and add it to the end of the input sting p 1. Afte finishing the DFS, we delete the minimum v of Q, add it to the end of the output sting p 2, and check whethe it has any childen ignoed duing the above DFS. If it does, then we take the ignoed subtee ooted at v, pefom DFS on the subtee, and do the same things as above (ignoe the appopiate nodes, visit in the coect ode, add elements to the end of p 1, and so on. If it doesn t, then we delete the minimum of Q and epeat the pocedue. It is clea that afte we have visited all nodes of T, (p 1 ; p 2 is an allowable pai of pemutations of S. Figues 1 and 2 show the pseudo-code fo the above algoithm. Example. Let T be a tee on f1; 2; : : :; 10g [ fg, shown in Figue 3, with the usual ode on f1; 2; : : :; 10g. Duing the pocess of finding (T by the above algoithm, the vaiables p 1, p 2 and Q change in the way shown in Figue 4. Fom the last step we get (T = ((6 8 3 10 1 2 9 7; (1 3 2 4 5 6 8 10 7 9: It may be noted that in the case in which T is inceasing, so that only one DFS is pefomed, p 2 is the unique inceasing pemutation of S and educes to a well-known bijection fom inceasing ooted labeled tees to pemutations. (See, fo example, Stanley [5]. 3 Constuction of To descibe the invese map : P! T, we fist descibe a function that associates to an allowable pai (p 1 ; p 2 a sequence of Inset and Delete-Minimum opeations that tansfoms p 1 to p 2. We epesent the sequence of opeations as a sequence of I s and D s, which we call an I-D sequence. A sequence of n I s and n D s epesents a valid I-D sequence if and only if evey pefix has at least as many I s as D s. It

A Bijective Appoach 3 pocedue getinput(s; comment pefom DFS on the unvisited subtee ooted at s; begin w := s; comment w epesents whee we ae in the subtee; while w 6= the paent of s do begin comment this condition is only used to check if the DFS is finished; comment we can take any nonelement of S [ fg as the paent of fo the case s = ; if w 6= s and all the childen of w lage than w ae maked then w := the paent of w; else begin w := the lagest unmaked child of w; mak w add w to the end of p 1 ; inset w into Q; Figue 2: Algoithm fo the suboutine getinput. 7 9 Figue 3: An Example of a ooted labeled tee.

4 Pemutational Powe of a Pioity Queue Step p 1 p 2 Q 1 (6 f6g 2 (6 8 f6; 8g 3 (6 8 3 f3; 6; 8g 4 (6 8 3 10 f3; 6; 8; 10g 5 (6 8 3 10 1 f1; 3; 6; 8; 10g 6 (6 8 3 10 1 (1 f3; 6; 8; 10g 7 (6 8 3 10 1 (1 3 f6; 8; 10g 8 (6 8 3 10 1 2 (1 3 f2; 6; 8; 10g 9 (6 8 3 10 1 2 5 (1 3 f2; 5; 6; 8; 10g 10 (6 8 3 10 1 2 (1 3 f2; 4; 5; 6; 8; 10g 11 (6 8 3 10 1 2 (1 3 2 f4; 5; 6; 8; 10g 12 (6 8 3 10 1 2 (1 3 2 4 f5; 6; 8; 10g 13 (6 8 3 10 1 2 (1 3 2 4 5 f6; 8; 10g 14 (6 8 3 10 1 2 (1 3 2 4 5 6 f8; 10g 15 (6 8 3 10 1 2 (1 3 2 4 5 6 8 f10g 16 (6 8 3 10 1 2 (1 3 2 4 5 6 8 10 17 (6 8 3 10 1 2 9 (1 3 2 4 5 6 8 10 f9g 18 (6 8 3 10 1 2 9 7 (1 3 2 4 5 6 8 10 f7; 9g 19 (6 8 3 10 1 2 9 7 (1 3 2 4 5 6 8 10 7 f9g 20 (6 8 3 10 1 2 9 7 (1 3 2 4 5 6 8 10 7 9 Figue 4: Finding (T.

A Bijective Appoach 5 pocedue findid(p 1 ; p 2 ; begin i := 1; j := 1; sequence := ; while i n and j n do begin while j < n and j < j+1 do j := j + 1; while i j o i 2 1 j do begin add I to the end of sequence; i := i + 1; k := j; add D to the end of sequence; while k > 1 and k?1 < k do begin add D to the end of sequence; k := k + 1; j := j + 1; i := i + 1; Figue 5: Algoithm fo finding the coesponding I-D sequence. 1 is well known that the numbe of such sequences is the Catalan numbe n+1? 2n n. The I-D sequence fo tansfoming p 1 to p 2 that we constuct will have the popety that each element is deleted as late as possible. To constuct it, we scan p 2 = 1 n fom the beginning until we find a descent, i.e., some j such that j > j+1 o j = n, and we stop at j. Next we scan p 1 = 1 n fom the beginning and add an I to the end of the I-D sequence fo each symbol we scan, until the next symbol i (not yet scanned is smalle than j and does not appea in the pefix 1 j. Now add j D s to the end of the I-D sequence. Go on to scan p 2 fom j+1 to the next descent j 0 ( j 0 > j 0 +1 o j 0 = n, and epeat the above pocess, adding (j 0? j D s to the end of the I-D sequence. Continue until p 1 and p 2 ae exhausted. The pseudo-code fo the above algoithm can be found in Figue 5. Lemma 0 Let (p 1 ; p 2 be an allowable pai. Then: 1 If 1 occus befoe 2 in p 2 and 1 > 2, then 1 occus befoe 2 in p 1 ; 2 If 1 occus befoe 2 in p 2, which occus befoe 3 in p 2, and 2 > 3, then 1 occus befoe 3 in p 1. Poof. See Atkinson and Thiyagaajah [1, p. 4]. Lemma 1 The I-D sequence obtained in the above algoithm poduces the output sting p 2 fom the input sting p 1 though a pioity queue Q, and among all I-D sequences that tansfom p 1 to p 2, this one deletes each element as late as possible.

6 Pemutational Powe of a Pioity Queue Poof. Fist we note that, if we use the I-D sequence obtained in the above algoithm to poduce an output sequence p 0 2 fom p 1, it woks in the following way: fist we scan p 2 fo descents; once we find a descent j > j+1, we stat inseting symbols of p 1, one by one, into the pioity queue Q until we find a symbol i of p 1 which is smalle than j but doesn t appea in the pefix 1 j. Next we delete minimal elements (minimal at the time of deleting of Q, one by one, and add them to p 0 2, as many times as the numbe of symbols between this descent of p 2 and the pevious one. Now suppose the algoithm woks coectly though the kth descent j of p 2, i.e., the fist j symbols of p 2 and p 0 ae identical. We look fo the next descent 2 j 0 and inset elements of p 1 to Q until we find an i 0 2 p 1 with i 0 < j 0 but i 0 62 1 j 0. We claim that at this time 1 j 0 2 Q; 2 all elements occuing between j and j 0 on p 2 ae in Q (note that all such elements ae less than j 0 since j and j 0 ae consecutive descents; 3 all elements in Q which ae less than j 0 fall between j and j 0 in p 2. Poof of the above assetions: 1 By 1 of Lemma 0, j 0 occus befoe i 0 in p 1 and j 0 has not yet been deleted by the hypothesis. 2 If l occus between j and j 0 in p 2, then by 2 of Lemma 0, l occus befoe i 0 in p 1 and again has not yet been deleted. So l 2 Q. 3 Let i, i 0 be symbols in p 1 as befoe. If l < j 0 and l occus afte j 0 in p 2, then l cannot lie between i and i 0 in p 1 and l 6= i if i 6= i 0, by ou algoithm. If j+1 = j 0, then j > j+1 = j 0 > l and l occus afte j in p 2, so eithe l = i (in this case l = i = i 0 o l lies afte i in p 1, and theefoe l 62 Q. If j+1 6= j 0 (and theefoe j+1 < j 0, by 2 of Lemma 0, j+1 occus befoe l in p 1. But by 2, j+1 2 Q and since j+1 < j and j was deleted fom Q afte all elements peceding i in p 1 had been inseted to Q, j+1 cannot pecede 1 in p 1 and hence l occus afte i in p 1. So l 62 Q. Now if l 0 2 Q and l 0 < j 0, then l 0 cannot occu afte j 0 in p 2, by the above agument, and l 0 can neithe be j no pecede it in p 2 by the hypothesis. So l 0 must lie between j and j 0 in p 2. Fom 1, 2, and 3 above, we conclude that the smallest (j 0? j elements in Q ae j+1 ; j+2 ; : : :; j 0. So the fist j 0 symbols of p 2 and p 0 ae also identical. By induction, 2 p 2 = p 0 2 and the I-D sequence obtained in the algoithm does poduce p 2 fom p 1 though a pioity queue. Now, wheneve a deletion is pefomed, the next symbol i in p 1 is smalle than some j 2 Q which must be output befoe i. So we can neve put off a deletion and eplace it by an insetion, i.e., with this I-D sequence, we delete each element fom Q as late as possible. With this I-D sequence, we can now constuct the ooted labeled tee (p 1 ; p 2. We stat with the oot node and a pointe pt to it, and two pointes pt1 and pt2 to scan p 1 and p 2, initially pointing to the position befoe the fist symbols of p 1 and p 2. Then we ead the I-D sequence, one lette at a time. When we ead an I, we take the next symbol i (if pt1 points to i?1 in p 1 and ty to add it to the tee in the following way: if the node to which pt points is the oot, o is the symbol in p 2 to which the pointe pt2 points, o is less than i, then make i a child of this node and let pt point to i ; othewise, let pt point to the paent of the node and ty again. When we ead a D, we move pt2 to the next symbol j and at the same

A Bijective Appoach 7 pocedue (p 1 ; p 2 ; comment constuct a ooted labeled tee fom an allowable pai (p 1 ; p 2 ; begin comment initialize; fom a node as the oot; v := ; comment v epesents pt; i := 0; comment i epesents pt1; j := 0; comment j epesents pt2; k := 1; comment k is the kth element of findid(p 1 ; p 2 ; while k 2n do begin if k = I then begin i := i + 1; while v 6= and v 6= j and i > v do v :=the paent of v; add a child i to the node v; v := i ; else begin comment k = D; j := j + 1; v := j ; k := k + 1; Figue 6: Algoithm fo the map. time let pt point to the node j in the tee. (It is clea that we have aleady constucted the node j by this time since p 2 can be poduced fom p 1 by this I-D sequence though a pioity queue. The pseudo-code fo the above algoithm can be found in Figue 6. Example. Let (p 1 ; p 2 = ((6 8 3 10 1 2 9 7; (1 3 2 4 5 6 8 10 7 9. The I-D sequence is poduced by the above algoithm in the way shown in Figue 7 (the undelined symbols ae those which the pointes ae pointing to. Then (p 1 ; p 2 is constucted by the algoithm in the way shown in Figue 8 (the cicled node is the one to which the pointe pt2 points, o if pt2 is at the position befoe the fist symbol of p 2. Theefoe, (p 1 ; p 2 is the last tee in the figue. 4 The Poof Lemma 2 Let T be a ooted labeled tee on S [ fg ooted at and m be the lagest element in S. If L is the subtee of T ooted at m and F = T n L, then 1 (T =! 1 (L and 2 (T = 2 (F m 2 (L

8 Pemutational Powe of a Pioity Queue Step p 1 p 2 sequence 1 (6 8 3 10 1 2 9 7 (1 3 2 4 5 6 8 10 7 9 IIIIIDD 2 (6 8 3 10 1 2 9 7 (1 3 2 4 5 6 8 10 7 9 IIIIIDDIIIDDDDDD 3 (6 8 3 10 1 2 9 7 (1 3 2 4 5 6 8 10 7 9 IIIIIDDIIIDDDDDDIIDD Figue 7: Finding the coesponding I-D sequence. whee = ( 1 ; 2,! = 1 i m i+1 k, 1 (F = 1 k, and i is the paent of m in T. Poof. Fist we obseve that if v 6= is any node in T and w is the fist incease node on the path fom v to (i.e., if v? 1? 2?? i?w?? is the (unique path fom v to, then v > 1 > 2 > > i but i < w, then v is visited by the pocedue getinput (and hence appeas in p 1 and is inseted to Q afte w is deleted fom Q. If thee is no such w, then v is inseted to Q befoe any output symbol is poduced. Theefoe, since m is the lagest element in S, any node v is a descendant of m in T if and only if v is inseted into Q afte m is deleted fom Q (the only if pat is obvious; to see the if pat, we can use the above obsevation and induction on the numbe of ascents in the path fom v to, and hence any node v is a descendant of m in T if and only if v is deleted fom Q afte m is (the only if pat follows fom the fact that m is the lagest element in S. Since Q is empty ight afte m is deleted, we conclude that 1 (T = 1 (F 0 1 (L and 2 (T = 2 (F 0 2 (L whee F 0 = T n (L n fmg, and the last symbol in 2 (F 0 is m. Moeove, it is clea that 1 (F and 2 (F ae obtained fom 1 (F 0 and 2 (F 0, by simply emoving the symbol m. So 2 (F 0 = 2 (F m. If 1 (F = 1 k and i is the paent of m, then clealy m is visited ight afte i is, and hence 1 (F 0 = 1 i m i+1 k. This concludes the poof of the lemma. Lemma 3 Let (p 1 ; p 2 be an allowable pai of pemutations of S, and let m be the lagest element in S. If p 2 = 2 m 2, j 2 j = k, and p 1 = 1 i m i+1 k 1, 1 = 1 k, then (p 1 ; p 2 is the tee obtained by 1 eplacing the oot of ( 1 ; 2 by m; call the esulting tee ^T 2 connecting ^T to ( 1 ; 2 so that m becomes a child of i. Poof. We wite 0 1 = 1 i m i+1 k and 0 2 = 2m fo convenience. Let s be the I-D sequence findid(p 1 ; p 2. If we use s to poduce p 2 fom p 1 though a pioity queue Q, then when we ead the (k+1st D of s, we ae deleting m, which is the lagest element in S, fom Q, and hence Q is empty afte that deletion. Theefoe, the sting s 1 consisting of the fist (2k + 2 symbols of s contains (k + 1 I s and (k + 1 D s. Moeove, if we wite s = s 1 s 2, then s 1 (esp. s 2 is an I-D sequence which can be used to poduce 0 2 (esp. 2 fom 0 1 (esp. 1 though Q with deletions as late as possible. Now we etun to ou constuction of (p 1 ; p 2. When m is scanned in p 2, the tee we have constucted is ( 0 1 ; 0 2 and the nodes of the emaining pat of (p 1; p 2 to be constucted ae descendants of m since evey node in ( 0 1 ; 0 2 except has aleady been scanned in p 2. Theefoe, the subtee of (p 1 ; p 2 ooted at m is ( 1 ; 2 with eplaced by m, and, if we call this tee ^T, (p 1 ; p 2 n ( ^T n fmg = ( 0 1 ; 0 2. Next, we take a close look at ( 0 1 ; 0 2. If we emove fom s 1 the I and D coesponding to m, then we get an I-D sequence s 0 1 which can be used to poduced 2 fom 1 though Q with deletions as late as possible. So ( 1 ; 2 can be obtained by deleting the leaf m fom ( 0 1 ; 0 2. Moeove, since s 1 deletes

A Bijective Appoach 9 6 6 8 3 6 3 6 8 10 8 10 8 10 8 10 8 5 9 7 9 7 9 7 9 Figue 8: Finding (p 1 ; p 2.

10 Pemutational Powe of a Pioity Queue elements fom Q as late as possible and m is deleted at the vey last step, no deletions occu between the insetions of i and m. Theefoe, m is a child of i in ( 0 1 ; 0 2 and hence (0 1 ; 0 2 can be obtained by adding a child m to the node i in ( 1 ; 2. We conclude that (p 1 ; p 2 is obtained by connecting ^T, which is ( 1 ; 2 with eplaced by m, to ( 1 ; 2 so that m becomes a child of i. This completes the poof. Theoem 1 = id P and = id T, and hence and ae bijections. Poof. We use induction on jsj. The theoem is clealy tue if jsj = 1. Lemma 2 implies that (T = (! 1 (L; 2 (F m 2 (L, whee m is the lagest element in S, L is the subtee of T ooted at m, F = T n L,! = 1 i m i+1 k, 1 (F = 1 k and i is the paent of m in T. By Lemma 3, (T is the tee obtained by connecting ^T, which is ( 1 (L; 2 (L with eplaced by m, to ( 1 (F ; 2 (F so that m becomes a child of i. But ( 1 (L; 2 (L = L and ( 1 (F ; 2 (F = F by induction hypothesis, so (T is the tee obtained by connecting ^T, which is L with eplaced by m, to F so that m becomes a child of i, i.e., (T = T. On the othe hand, by Lemma 3 (p 1 ; p 2 is the tee obtained by connecting ^T, which is ( 1 ; 2 with eplaced by m, to ( 1 ; 2 so that m becomes a child of i, whee m is the lagest element in S, p 2 = 2 m 2 (j 2 j = k, p 1 = 1 i m i+1 k 1 and 1 = 1 k. By Lemma 2, (p 1 ; p 2 = (! 1 (( 1 ; 2 ; 2 (( 1 ; 2 m 2 (( 1 ; 2 whee! = 1 j m j+1 k and 1 (( 1 ; 2 = 1 k, j = i. But 1 (( 1 ; 2 = 1, 2 (( 1 ; 2 = 2, 1 (( 1 ; 2 = 1, and 2 (( 1 ; 2 = 2, by the induction hypothesis, so (p 1 ; p 2 = ( 1 i m i+1 k 1 ; 2 m 2 = (p 1 ; p 2 : Coollay. The numbe of allowable pais of pemutations of an n-set is (n + 1 n?1. 5 Counting by Descents In the special case in which the output sequence is inceasing, the I-D sequence is I n D n, and the coesponding tee is also inceasing (i.e., each node is geate than its paent. It is easy to see that each descent of the output sequence coesponds in the I-D sequence to a symbol D that is followed by an I (hee we don t count the last symbol of a sequence as a descent and theefoe to a node of the coesponding tee that has smalle childen. Fom now on, we shall define such a node to be a descent of a tee. In this section it is convenient to take S to be the set f1; : : :; ng and the oot to be 0. We now count allowable pais accoding to the numbe of descents of the output sequence (which also counts tees ooted at 0 by descents. We fist assign the weight t d(p to an allowable pai p = (p 1 ; p 2, whee d(p is the numbe of descents of p 2. Let c n (t be the sum of the weights of all allowable pais p of pemutations of f1; : : :; ng, i.e., c n (t = t d(p : p

A Bijective Appoach 11 To find c n (t, we genealize the ecuence fomula of Atkinson and Thiyagaajah [1, p. 6]. Each allowable pai can be decomposed in the way descibed in Lemma 3: p 2 = 2 n 2 with j 2 j = k and p 1 = 1 i n i+1 k 1, 1 = 1 k. Moeve, thee ae k + 1 such pais p that can be obtained by combining two shote allowable pais = ( 1 ; 2, = ( 1 ; 2 with the geatest element n, which ae detemined by the choice of the position of n in p 1. To count the descents, we can easily see that d(p = ( d(; if 2 = 1 = ; d( + d( + 1; othewise since n is an additional descent in the latte case but not in the fome case. Hence we get c n (t = nc n?1 (t + n?2 k=0 (k n? + 1 1 k fo n 1, with c 0 (t = 1. Let F (x be the exponential geneating function fo c n (t, i.e., 1 Fom (1 we get n=0 c n+1 (t xn n! which is, in tems of F (x, o Integating both sides, we get o = (1? t Replacing txf (x by f (x, we get 1 n=0 F (x = 1 n=0 (n + 1c n (t xn c n (t xn n! :! n! + t 1 k=0 tc k (tc n?k?1 (t (1 (k + 1x k k! 1 F 0 (x = (1? t(f (x + xf 0 (x + tf (x(f (x + xf 0 (x F 0 (x tf (x + 1? t = F (x + xf 0 (x: 1 log(tf (x + 1? t = xf (x t tf (x + 1? t = e txf (x : j=0 c j (t xj f (x = x(e f (x + t? 1: (2 By the Lagange invesion fomula (see, fo example, Knuth [2, p. 392], we have [x n ]f = 1 n [xn?1 ](e x + t? 1 n ; fo n 1, whee [x n ] denotes the coefficient of x n. Thus fo n > 0, [x n ]f = 1 n n n k=0 = 1 n k=0 n k n k!! [x n?1 ](e x? 1 k t n?k k! n? 1 t n?k ; (n? 1! k j! ;

12 Pemutational Powe of a Pioity Queue whee n k is the Stiling numbe of the second kind (see Knuth [2, x1.2.6 and p. 90]. Theefoe, c n (t = n! [x n ]F n + 1 k! n k n! k k=0 n n! n t n?k (n + 1? k! k k=1 = n! t [xn+1 ]f = n! n+1 t 1 n + 1 =! t n+1?k since f n g n+1 = f n g 0 = 0. It also follows fom (2 and the popeties of exponential geneating functions that the coefficient of t k x n =n! in f (x is the numbe of ooted tees on f1; : : :; ng with k leaves, and fom this we may easily deive that fo n > 0, the coefficient of t k?1 x n =n! in F (x is the numbe of tees on f0; 1; : : :; ng ooted at 0 with k leaves. (This esult may also be deived fom Knuth [2, execise 19, p. 397; solution, p. 585] o fom Moon [4, Theoem 3.5, p. 20]. We may summaize ou esults as follows: Theoem 2 Let n?1 c n n! n (t = t k : (k + 1! n? k Then fo n > 0, (i (ii (iii k=0 c n (t = p t d(p ; whee the sum is ove all allowable pais p = (p 1 ; p 2 of pemutations of f1; : : :; ng and d(p is the numbe of descents of p 2 ; c n (t = T t d(t ; whee the sum is ove all labeled tees T on f0; : : :; ng ooted at 0 and d(t is the numbe of descents of T ; c n (t = T t l(t?1 ; whee the sum is ove all labeled tees T on f0; : : :; ng ooted at 0 and l(t is the numbe of leaves of T.

A Bijective Appoach 13 Refeences [1] M. D. Atkinson and M. Thiyagaajah. The pemutational powe of a pioity queue. BIT, 33:2 6, 1993. [2] D. E. Knuth. Fundamental Algoithms: The At of Compute Pogamming, volume 1. Addison-Wesley, Reading, Massachusetts, 1968. [3] D. E. Knuth. Soting and Seaching: The At of Compute Pogamming, volume 3. Addison-Wesley, Reading, Massachusetts, 1973. [4] J. W. Moon. Counting Labelled Tees. Canadian Mathematical Congess, Monteal, 1970. [5] R. P. Stanley. Enumeative Combinatoics, volume 1. Wadswoth & Books/Cole, Monteey, Califonia, 1986.