Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

15-251 QUIZ 1 SOLUTIONS

Rudich and Maggs

Feb 21, 2000

Solutions prepared by Dominic Mazzoni and Patrick Riley


1. Express the sum 1 + 2 + 3 + . . . + n as a binomial coefficient. (5 points)
You know that by Gausss formula, this sum is n(n + 1)/2, which happens to be the
same as the binomial coefficient (n + 1) choose 2, so the answer is just:
!

n+1
2
Another acceptable answer would be
coefficient received full credit.

n+1
n1

. Only answers in the form of a binomial

2. How many ways are there of dividing k bars of gold among n pirates?
points)

(5

This is the just the old pirate question again


!

n+k1
n1
or

n+k1
k

3. How many ways are there of ordering n distinct items? (5 points)


n!
4. According to the binomial formula, what is the expansion of (x + y)n ?
points)
n
X

k=0

n k nk
x y
k

or equivalently
n
X

k=0

n
xk y nk
nk

(5

5. n people enter a ping-pong tournament. Every two players get to play each
other exactly once. Show that no matter what the outcome of the individual
games (no ties in ping-pong), it is always possible to order the n players
such the ith player in your ordering beat the i + 1th player in your ordering
(for all i from 1 to n 1). (10 points)
We shall proceed by induction.
Induction Hypothesis: Given n players who play each other exactly once, it is always
possible to order the n players such that the ith player in our ordering beat the i + 1th
player in our ordering (for all i from 1 to n 1).
Base case: n = 2: One person always wins, so this ordering is always possible.
Induction step: Given n + 1 players, we shall remove one player, call her Sally, and
show that an ordering can be constructed. By the induction hypothesis, after removing
Sally, the n players can be ordered. Sally will meet one of the following: She either
beat someone or beat no one. If she beat someone, Sally is inserted ahead of the first
person she beat. This cannot break our ordering, because we know she did not beat
anyone before this, and she is known to have beaten the next person down (and, if
Sally beats anyone, there exists a first person that she beat). If she beat no one, insert
Sally at the end of the ordering. This cannot break our ordering either, since the
next-to-last person beat Sally.
(Many people took a tournament of n players and added a new person Sally. This is a
dangerous tactic to use in an inductive proof. You should start with a tournament of
size n + 1 and proceed (using the the inductive hypothesis for n), rather than starting
with n and building up to n + 1.)
6. How many different Two Pair hands are there in poker?
There are 13 ways to choose the first rank,

 
4
2

(10 points)

ways to choose the suits, 12 ways to

 
4
2

choose the second rank,


ways to choose those suits, and then 44 ways to choose
the remaining card. However, the first pair and the second pair are interchangeable,
so we have to divide by 2! in order to avoid overcounting:
!

4
4
1
13
12
44 = 123, 552
2
2
2
Another explanation is to choose the 2 different ranks for pairs
for those ranks

 2
4
2

 
13
2

, then choose suits

, and then 44 ways to choose the remaining card.


!

13
4
4

44 = 123, 552
2
2
2
2

Another explanation is the following: Choose any card (52). Then choose another
card of the same rank (3). However, we overcounted by 2 since order does not matter.
Then, choose a card of a different rank (48), and then choose a card of the same rank
(3). Once again we overcounted by 2. Choose the last card to be of different rank then
the ones we have chosen (44). However, we have once again overcounted by 2 since the
order of the pairs does not matter.
523
2

483
2

44

= 123, 552

7. How many distinct ways are there to rearrange the letters in PEPPERONIPIZZA? (10 points)
There are 4 Ps, 2 Es, 2 Is, 2 Zs, and 1 each of RONA. This is just the multinomial
coefficient.
!

14
14!
=
= 454, 053, 600
4; 2; 2; 2; 1; 1; 1; 1
4!2!2!2!
8. Prove by induction: F0 + F1 + . . . + Fn = Fn+2 1.

(10 points)

Base case: F0 = F2 1. The zeroth Fibonacci number is 0, and the second is 1, so its
true.
Induction hypothesis: Suppose that for some particular value of n:
F0 + F1 + . . . + Fn = Fn+2 1
Induction step:

F0 + F1 + . . . + Fn
F0 + F1 + . . . + Fn + Fn+1
F0 + F1 + . . . + Fn + Fn+1
F0 + F1 + . . . + Fn + Fn+1

=
=
=
=

Fn+2 1
Fn+2 1 + Fn+1
(Fn+1 + Fn+2 ) 1
Fn+3 1

which shows that the equation is true for n + 1, so by the principle of Induction, this
equation holds for all n 0.
9. Here is a correct algorithm for sorting the elements of an n-element sequence.
3

(a) If n = 1, the sequence is already sorted. Return.


(b) Recursively sort the first d2n/3e elements.
(c) Recursively sort the last d2n/3e elements.
(d) Recursively sort the first d2n/3e elements.
Write a recurrence to express the running time of this algorithm.
points)

(10

Unfortunately, as stated this program will loop forever whenever it gets to the case
where n = 2. It is not clear what the correct recurrence should be as a result of this
error, so everyone received a full 10 points on this problem.
If there had been a base case that sorted any sequence of length 2 (by swapping the
two elements if they were out of order), then the algorithm would have been correct,
and the recurrence would have been:
T (n) = 3T (

2n
)) + O(1), T (1) = O(1), T (2) = O(1)
3

Extra credit (10 points): Solve your recurrence. (Only worth points if
recurrence is correct.)
(Because of the error in the problem, we accepted any solution to a recurrence that was
clearly explained and justified, even if it solved a slightly different recurrence.)
2n
)) + O(1)
3
4n
= 9T ( )) + 3 O(1) + O(1)
9
8n
= 27T ( )) + 9 O(1) + 3 O(1) + O(1)
27
..
.

T (n) = 3T (

2(k2) n
)) + 3(k2) O(1) + . . . + 3 O(1) + O(1)
3(k2)
= 3k1 O(1) + 3k2 O(1) + . . . + 3 O(1) + O(1)
3k 1
=
O(1)
2
= 3(k2) (

Here, k is the depth of the recursion, which is log3/2 n. So we have


which equals 12 (nlog3/2 3 1), which is O(n2.71 ).

1
2

(3log3/2 n 1),

10. How many arrangements of 5 0s and 10 1s are there with no pair of


consecutive 0s? (15 points)
(a) Heres one way to solve the problem. Lets start by placing five zeroes, with four
ones in-between them:
010101010
Now all we need to do is place the remaining six ones. These remaining ones can
be placed on either end, or they can be placed next to some of the ones already
there. Here are all of the places we can put ones:
01

01

01

01

In each of the blank spots indicated, we can put as many 1s as we want, and so
all we need to do is count the number of ways to put the six 1s into six spots,
where any spot can contain between 0 and 6 1s. This is the same
as the number

6+61
of ways to divide six bars of gold among six pirates, which is
.
6
(b) Heres another solution. Place the ten 1s first, and think of them like slashes.
Now we need to put the 0s into any of the spaces between 1s, with at most
 0 in
any one of the spaces. There are 11 spaces, and 5 0s, so the answer is 11
.
5
(c) Heres yet another approach. Group each 0 with a 1 so that it always has a 1
protecting it from other 0s. So now we have these ten indivisible units:
01 01 01 01 01 1 1 1 1 1
 

All we need to do is figure out how to arrange these, which is just 10


. However,
5
this doesnt count any of the arrangements which end in a 0, so lets split one of
the 01s and put the 0 at the end. Now we need to arrange these:
01 01 01 01 1 1 1 1 1 1
 

There are 10
ways to do this, and this counts the number of arrangements of 0s
4
and 1s such that there is a 0 at the end, and no consecutive 0s anywhere.
 Adding
 
10
this to the number of arrangements without a zero on the end gives 10
+
5
4
which is the same as

 
11
5

11. How many ways are there for 10 people to have 5 simultaneous telephone
conversations? (15 points)
5

(a) Choose the first two people to have the first conversation:
people left. Choose the next two:

 
8
2

 
10
2

. There are eight

. Choosing the next pairs are

   
6
2

4
2

, and

 
2
2

. Multiplying all of these together gives us the total number of different ways
ten people could have started five conversations if the order mattered, but we
dont care in which order the conversations started, so we divide by 5! to get:
     
10
2

8
2

6
2

4
2

2
2

5!
(b) You can also look at the problem this way. Put the 10 people in any arbitrary
order. The first person could be talking to any one of the other nine. Pair them off
and remove them. The new first person could be talking to any of the remaining
seven, so pair them off and remove them from the order. Keep doing this until
everyone is paired, and the number of possible ways to do this is just 9*7*5*3*1.
Note that this did not depend on the initial order of the people in any way, and
that all of the choices we made were unique, which is why it satisfies the Sleuths
Criterion.

You might also like