• Non ci sono risultati.

Preimages under the Queuesort algorithm

N/A
N/A
Protected

Academic year: 2021

Condividi "Preimages under the Queuesort algorithm"

Copied!
1
0
0

Testo completo

(1)

DIMAIDIPARTIMENTO DI

MATEMATICA E INFORMATICA “ULISSE DINI”

Preimages under Queuesort

Lapo Cioni, Luca Ferrari

lapo.cioni@uni.it, luca.ferrari@uni.it

Synopsis

Queuesort is an algorithm which tries to sort an input permutation π by using a queue. Similarly to what has been done for Stacksort (more recently by Defant and less recently by Bousquet-Mélou), we study preimages of permutations under Queue-sort.

Characterization of preimages. Alterna-tive way of describing the output q(π) of Queuesort on input π. Recursive character-ization of preimages of a given permutation, from which we deduce a recursive procedure to generate them.

Enumeration of preimages. Enumeration

of q−1

(M1P1M2), where M1, M2 are all the

maximal sequences of LTR maxima of π

(with M2 possibly empty): combinations of

Catalan numbers. Catalan numbers when

|M2| = 1. Enumeration of permutations

with one preimage: derangement numbers.

The algorithm Queuesort

for i=1 to n do begin

if (Q=∅ or BACK(Q)<πi) then ENQUEUE

else begin

while FRONT(Q)<πi do DEQUEUE

OUT end end

while Q6= ∅ do DEQUEUE

Description of Queuesort on permutations

Read the permutation from right to left, and move each LT R − maxima to the right till we nd a number bigger than it. bc bc bc bc bc 1 − → bc bc bc bc bc 1 − → bc bc bc bc bc 1 − → bc bc bc bc bc 1

Preimage not empty

Let π = π1 · · · πn. Then q−1(π) 6=

∅ if and only if πn = n.

Notation

π = M1P1 · · · Mk−1Pk−1Mk, in

which the Mi's are all the maximal,

nonempty sequences of consecutive

LT R − maxima. Sometimes we

will use Ni and Rj instead of Mi

and Pj, respectively.

Characterization of preimages

If π is not the identity permutation, then every preimage σ of π is one and only one of the following:

ˆ σ = q−1(M

1P1 · · · Mk−2Pk−2Mk−10 n)mk−1,mk−1Pk−1Mk0 , where

Mk−10 is obtained by removing the last element mk−1,mk−1 from

Mk−1, while Mk0 is obtained by removing n from Mk;

ˆ let π0 be the permutation obtained by removing n from π; for every

preimage σ0 = N

1R1 · · · Ns−1Rs−1Ns of π0, σ is obtained by inserting

n in one of the positions to the right of Ns−1.

Associated algorithm

ˆ compute all the preimages of

M1P1 · · · Mk−2Pk−2Mk−10 n,

and concatenate them with

mk−1,mk−1Pk−1Mk0 ;

ˆ if |Mk| ≥ 2, then compute a

preim-age σ0 = N

1R1 · · · Ns−1Rs−1Ns of

M1P1 · · · Mk−1Pk−1Mk0 , and insert

n in each of the positions to the

right of Ns−1. 23145 25 25 25314 52 52314 2314 24 24 2431 24531 24351 24315 4231 42 45231 42531 42351 42315 1

Remark

The number of preimages is uniquely determined by the posi-tions of its LT R − maxima.

Permutations with one preimage

A permutation π ∈ Sn has exactly one preimage if and only if it ends

with n and has no adjacent LT R − maxima. As a consequence, using

Foata's fundamental bijection, |{π ∈ Sn | |q−1(π)| = 1}| is the number of

derangements of length n − 1.

Preimages of M

1

P

1

n

Let π = M1P1M2, with |M2| = 1.

Then q−1(π) = |C

m1|, where Ck is

the k-th Catalan number.

Preimages of π = M

1

P

1

M

2 Let π = M1P1M2 ∈ Sn. Then |q−1(π)| = m2 X i=1 i−1 X j=0 i − 1 j  m1−2 X l=0  m1 − l j + 1  bm1−1,l+1 ! m2−i+1 X k=2 gm2−i,k  k p1 + i − j − 1 !

where br,s = A009766(r, s), and gr,s = A033184(r, s − 1) are two dierent incarnations of the ballot numbers.

In the above formula, the sum involving the br,s's can be rewritten as

m1−2 X l=0  m1 − l j + 1  bm1−1,l+1 = b j+12 c+1 X i=1 (−1)i−1j + 2 − i i − 1  Cm1+j+1−i.

This shows that |q−1(π)| can be expressed as a combination of Catalan numbers.

1

Q

Riferimenti

Documenti correlati

Models based on intensity have been elaborated exploiting some stochastic differential equations, for example CIR-short rate models.. That

Viste le buone prestazioni nella compressione/elaborazione dell'immagine, è ragionevole chiedersi se esistano altri campi in cui l'utilizzo della F-transform possa

Monte Capra Breccia (“Breccia di M. Capra” in the map) This is a massive, polygenic breccia, with Fe-gabbro and minor Fe-basalt, plagiogranite, Mg-basalt and serpentinite clasts, in

What we are facing now is the result of processes that have developed during the last dec- ades in philosophy, sociology, communication studies, and journalism studies. We can indicate

consumption of online news 60 and on their engagement with those same news (i.e. shar- ing) in social media has shown, the act of sharing news (and thus circulating and

Euroasiatic: species mainly diffused in the temperate regions of Europe and Asia (Euras), or limited to western Europe and Asia (EurWAs) or southern Europe and

The International Classification of High-Resolution Computed Tomography for Occupational and Environmental Respiratory Diseases is a powerful and reliable tool for

Veronesi U, Paganelli G, Galimberti V, Viale G, Zurrida ST, Bodeni N, Costa A, Chicco C, Geraghty JG, Luine A, Sac- chini V, Veronesi P (1997) Sentinel node biopsy to avoid