Final
Final
Final
Final Examination
Your name:
Circle the name of your Tutorial Instructor: David Hanson Jelani Sayan
This exam is closed book, but you may have a one page, twosided personal crib sheet.
There are 12 problems totaling 200 points. Write your solutions in the space provided, if
need be running over to the back of the page. Total time is 180 minutes. GOOD LUCK!
DO NOT WRITE BELOW THIS LINE
1 15
2 20
3 15
4 15
5 15
6 15
7 20
8 20
9 15
10 15
11 15
12 20
Total 200
If (1) holds, some of the assertions below must always (A) hold, some can (C) hold but
not always, and some can never (N) hold. Indicate which case applies for each of the
assertions by circling the correct letter.
(a) (5 points) Write a simple formula for the number of possible starting sequences.
If (s1 , . . . , sk ) is a sequence of numbers, then the i and jth elements of the sequence are out
of order if the number on the left is strictly larger the number on the right, that is, if i < j
and si > sj . Otherwise, the ith and jth elements are in order. Define p(S)::= the number
of “outoforder” pairs of elements in a sequence, S.
From the starting sequence, we carry out the following process:
(*) Pick two consecutive elements in the current sequence, say the ith and (i + 1)st.
I. If the elements are not in order, then switch them in the sequence and repeat step
(*).
II. If the elements are in order, remove both, resulting in a sequence that is shorter by
two. Then pick another element and remove it as well. If the length of the resulting
sequence is less than three, the process is over. Otherwise, reverse the sequence
and repeat step (*).
This process can be modelled as a state machine where the states are the sequences that
appear at step (*).
Final Examination Your name: 4
(b) (5 points) Describe a simple state invariant predicate that immediately implies that
if this process halts, then the final state is the sequence of length zero. (Just define the
invariant; you need not prove it has the requisite properties.)
(c) (10 points) Prove that this process always terminates by defining a nonnegative inte
ger valued derived variable that is strictly decreasing. (Just define the variable, you need
not prove it has these properties.)
Final Examination Your name: 5
(a) (8 points) Exhibit two planar drawings of the same 5vertex graph in which a face in
one drawing has more edges than any face in the other drawing.
(b) (7 points) Prove that all planar drawings of the same graph have the same number
of faces.
Final Examination Your name: 7
a, d, e, f, i, l, o, p, r, s,
is called a cword. A password will be a cword which does not contain any of the subwords
”fails”, ”failed”, or ”drop”.
Use the Inclusionexclusion Principle to find a simple formula for the number of pass
words.
Final Examination Your name: 8
(a) (5 points) Seashells are used for currency on a remote island. However, there are
only huge shells worth 210 dollars and gigantic shells worth 312 dollars. Suppose islander
A owes m > 0 dollars to islander B. Explain why the debt can be repaid through an
exchange of shells provided A and B both have enough of each kind.
(b) (10 points) Give an inductive proof that the Fibonacci numbers Fn and Fn+1 are rela
tively prime for all n ≥ 0. The Fibonacci numbers are defined as follows:
(b) (10 points) Now use the fact that the expected number of heads in n tosses of a fair
coin is n/2 to give a different proof of equation (2).
Final Examination Your name: 10
(a) (8 points) Write a generating function for each of the four doughnut types:
G(x) = C(x) =
P (x) = S(x) =
• If the drawn ball is black, then a biased coin with probability, p > 0, of coming
up heads is flipped. If the coin comes up heads, a white ball is put into the box;
otherwise the black ball is returned to the box.
(a) (5 points) What does Markov’s bound tell us about the probablity that my algorithm
takes longer than 1 minute (= 60 seconds)?
(b) (5 points) Suppose I decide to run the algorithm for 1 minute and if I don’t get an
answer by that time, I stop what I am doing, and completely restart from scratch. Each
time that I stop and restart the algorithm gives me an independent run of the algorithm.
So, what is an upper bound on the probability that my algorithm takes longer than 5
minutes to get an answer?
(c) (5 points) Suppose some 6.042 student tells me that they determined the variance of
the running time of my algorithm, and it is 25. What is an upper bound on the probability
that my algorithm takes longer than 1 minute?
Final Examination Your name: 14
1 + 2�
2−n(1−H((1/2)−�))
�
� � �
� Sn �
Pr �
− p
�
≥ �
≤
� � ·
� (3)
n 2� 2π(1/4 − �2 )n
where
H(α) ::= −α log2 α − (1 − α) log2 (1 − α).
(a) (10 points) Explain how to use the Binomial Sampling Theorem to find n0 . You are
not expected to calculate any actual values, but be sure to indicate which values should
be plugged into what formulas.
Final Examination Your name: 15
(b) (10 points) The calculations in part (a) depend on some facts about the run and how
the n wafers in the sample are chosen. Write T or F next to each of the following state
ments to indicate whether it is True or False.