• Aucun résultat trouvé

Homework due to the November 4, 2010

N/A
N/A
Protected

Academic year: 2022

Partager "Homework due to the November 4, 2010"

Copied!
2
0
0

Texte intégral

(1)

1

UE Mathematics for Computer Science

Homework, October 2010

Counting stacks

(10 points)

Consider a stack with the two primitives push and pop. An execution of a program consists innoperationspushandnpopwhich could be interleaved. The execution is represented by a mountain, the functionm(k)that gives the level of the stack afterkoperations.

Level of the stack

2n k

m(k)

Denote by Mn the number of mountains with n push (up-stroke) and n pop (down-stroke) operations and setM0 = 1.

Question 1.1 : Smallncases

Forn = 1,2,3give the possiblemountainsand deduceM1,M2,M3.

Question 1.2 : Graph formulation

Propose a formulation of the problem as a path problem in a graph.

An extendedmountainof length2nwithnup-strockes andndown-strockes allows to be under the sea level (bad mountains):

Level of the stack

2n

Question 1.3 : Extendedmountains

Compute the number of extended mountains with length2n.

(2)

2

The flip operation consists in exchanging all the slopes after the first passage below0:

Flipped path Level of the stack

2n 0

−2

Mountain flipped atkfirst point beneath0

Question 1.4 : Flipped mountains

Show that the set of badmountainsis in bijection with the set ofmountainswith n−1up-strokes andn+ 1down-strokes.

Question 1.5 : Computation Prove that

Mn= 1 n+ 1

2n

n

= 2n!

(n+ 1)!n!. (1)

Question 1.6 : Recurrence relation

Show directly on mountain diagrams that theMnnumbers satisfy the recurrence equation:

Mn=M0Mn−1 +M1Mn−2+· · ·+Mn−1M0. (2)

Question 1.7 : Random mountains

From a uniform random generatorrandom()propose an algorithm that generates mountains uniformly.

BAD OK

Some shaking hands configurations withn= 3

OK

Question 1.8 : Shake hands

Suppose that 2n persons are seated around a table, how many ways could they shake hands without crossing ?

Question 1.9 : Generating function

From the recurrence equation 2 compute the generating function of the sequence and deduce formula 1.

Références

Documents relatifs

While most of the Minnesota collection is also available on the Internet, documents from the British American Tobacco Company stored in England are not, except for a small subset

Commanders of high performing teams have in shift 4 a stronger inhibition that a New Message is followed by a Show Information or that a Show Information is fol- lowed by a

Commanders of high performing teams have in shift 4 a stronger inhibition that a New Message is followed by a Show Information or that a Show Information is fol- lowed by a

Table 114 Results of multiple regression, predicting performance shift 3, with input and summary level process variables, and task adaptive behavior variables controlling

an element of R which is not in I)

Give a proof that you list all possible values, and for each value give an

[r]

Les nombres de Catalan forment une suite d’entiers naturels utilisée dans divers problèmes de dénom- brement, impliquant souvent des objets définis de façon récursive, comme