



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Exam 1.
(1) How many ways are there to distribute 8 different toys and 8 identical candy to 3 children (a) without restrictions; (b) if first child should get exactly 2 toys; (c) if the first child should get at least 2 toys?
Solution. (a) There are 3^8 ways to distribute toys and
ways to distribute candy (using the formulas for ordered and
unordered selection with repetition respectively). Therefore the answer
is 3^8 ×
(b) Here the number of ways to distribute toys changes. Namely
there are
ways to select the toys for the first child and 2^6 ways
to distribute remaining toys among the two other children. Therefore
the answer is
(c) The complimentary event is that the first child gets either 0 or 1 toy. Arguing as in part (b) we conclude that there are
38 −
ways to distribute toys. Therefore the answer is
[ 38 − 8 × 27 − 28
(2) (a) Write a generating function for the number of ways a given number n can be represented as a sum of two odd and three even numbers. (b) Find a number of ways 50 can be represented as a sum of two odd and three even numbers.
Solution. (a) We have
f (x) = (x + x^3 + x^5 + · · · + x^2 k+1^ +... )^2 (1 + x^2 + x^4 + · · · + x^2 k^ +... )^3. 1
Summing geometric progressions we find
x+x^3 +x^5 +· · ·+x^2 k+1+· · · =
x 1 − x^2
1+x^2 +x^4 +· · ·+x^2 k+· · · =
1 − x^2
Therefore
f (x) =
x^2 (1 − x^2 )^5
(b) Substituting y = x^2 into the formula
(1 − y)^5
k=
k + 4 4
yk
we get
x^2 (1 − x^2 )^5
= x^2
k=
k + 4 4
x^2 k^ =
k=
k + 4 4
x^2 k+2.
Coefficient in front of x^50 corresponds to 2k + 2 = 50, that is k = 24.
Thus the answer is
(3) Find a bounded solution to the recurrence relation
2 an = 5an− 1 − 2 an− 2 , a 0 = 1.
The characteristic polynomial is 2λ^2 − 5 λ + 2. The roots are 2 and 1 / 2. Therefore the general solution takes form an = A 2 n^ + B
2
)n
. The solution is bounded if and only if A = 0. From the the initial condition we have a 0 = B = 1. Therefore an =
2
)n .
(4) A bridge hand is called weak in a suit if it has neither ace nor king nor queen in this suit. (a) Find a number of bridge hands which are weak in at least one suit. (b) Find a number of bridge hands which are weak in exactly one suit.
Solution. Let A 1 be all hands which are weak in hearts, A 2 be all hands which are weak in diamonds, A 3 be all hands which are weak in spades and A 4 be all hands which are weak in clubs.
Exam 2.
(1) How many arrangements of the letters PEPPERMILL (a) do not start and end with the same letter; (b) have at least one P in the same position as in the original word; (c) have all Es in the first half? Solution. (a) There are P10;3, 2 , 2 , 1 , 1 , 1 arrangements of the letters PEPPERMILL. Among those P8;1, 2 , 2 , 1 , 1 , 1 start and end with P (since only places from 2d to 9th need to be specified), P 8 , 3 , 2 , 1 , 1 , 1 start and end with E and P 8 , 3 , 2 , 1 , 1 , 1 start and end with L. Therefore the answer is 10! 3!2!2!
(b) Let A 1 be all arrangements with P at the first place, A 3 be all arrangements with P at the third place, A 4 be all arrangements with P at the fourth place. Arguing as in part (a) we get |A 1 | = (^) 2!2!2!9! , |A 1 A 2 | = (^) 2!2!8! |A 1 A 2 A 3 | = (^) 2!2!7!. By inclusion exclusion formula
(c) There are
ways to choose places for E and P8;3, 2 , 1 , 1 , 1 to
arrange remaining letters. Therefore the answer is ( 5 2
(2) Find the generating function for a sequence satisfying
an = 7an− 1 − 5 an− 4 + n, a 0 = 0, a 1 = 1, a 2 = 2, a 3 = 3.
Solution. We have ∑^ ∞
n=
anxn^ =
n=
7 an− 1 xn^ −
n=
5 an− 4 xn^ +
n=
nxn.
The left hand side equals
f (x) −
n=
anxn^ = f (x) − (x + 2x^2 + 3x^3 ).
On the right hand side the first term is x(f (x) − (x + 2x^2 ) the second term is x^4 f (x) and the last term is
x
n=
nxn−^1 = x
n=
xn
= x
x^4 1 − x
4 x^4 − 3 x^5 (1 − x)^2
Solving the equation
f (x) − (x + 2x^2 + 3x^3 ) = x[f (x) − (x + 2x^2 )] + x^4 f (x) +
4 x^4 − 3 x^5 (1 − x)^2
we get
f (x) =
x − x^2 + 3x^4 − 2 x^5 (1 − x)^2 (1 − x − x^4 )
(3) Consider the following algorithm for finding two largest among n numbers. Divide the numbers into two equal groups, find the largest in the first (M 1 > m 1 ) and the second (M 2 > m 2 ) group and then find the two largest numbers among M 1 , M 2 , m 1 , m 2 by using at most three comparisons (m 1 to M 2 , m 2 to M 1 and M 1 to M 2 ). Find the recurrence relation for the number of comparisons needed in the worst case and solve it for n = 2k.
Solution. The recurrence relation is an = 2an/ 2 + 3, a 2 = 1.
Letting bk = a 2 k we get
bk = 2bk− 1 + 3, b 1 = 1.
A constant C satisfies this relation if C = 2C + 3, that is C = − 3. Thus the general solution of our relation is
bk = A 2 k^ − 3.
From 1 = b 1 = 2A − 3 we get A = 2. Therefore bk = 2 × 2 k^ − 3 Since n = 2k^ we have an = 2n − 3.
(4) How many ways are there to put 10 identical red balls and 10 different blue balls into 4 boxes so that there is a box containing (a) exactly 2 red balls; (b) exactly 2 blue balls? Solution. (a) Let A 1 be all distributions of red balls with exactly 2 balls in the first box, A 2 be all distributions with exactly 2 balls in the second box, A 3 be all distributions with exactly 2 balls in the third box, A 4 be all distributions with exactly 2 balls in the fourth box.