CPSC 320 Sample Midterm 2
November 2010
[6] 1. Short Answers
[3] a. If we can not use a recursion tree to prove a tight bound on the value of a func
tion
T
(
n
)
defined by a recurrence relation, can we use the Master theorem instead?
Explain why or why not.
Solution :
The proof of the Master theorem used recursion trees, so if we can use
the Master theorem to prove a bound on
T
(
n
)
then we can also use recursion trees.
Hence if we can not use recursion trees, then we can not use the Master theorem
either.
[3] b. The first (and only) result we looked at in our outline of the proof of the Master
theorem stated that
T
(
n
) =
n
log
b
a
+
t

1
summationdisplay
i
=0
a
i
f
(
n/b
i
)
Explain where the term
a
i
f
(
n/b
i
)
came from, by relating each factor to the tool we
used to prove the lemma.
Solution :
The
i
th
row of the recursion tree contained
a
i
nodes, since each node
of the tree has
a
children.
Each node worked on
n/b
i
elements (the size of the
subproblems at one level are
1
/b
th
the size of the subproblems at the next higher
level), hence doing
f
(
n/b
i
)
work.
[5] 2. In class, we looked at an implementation of a binary counter, and proved that if we use as
potential function
Φ(
D
i
)
the number of
1
bits in the counter, then the amortized cost of an
INCREMENT
operation is in
Θ(1)
. Suppose instead that we had used the number of
0
bits
in the counter as the potential function (note: this breaks the requirement that
Φ(
D
0
) = 0
,
so it would not be a valid choice). What would the amortized cost of
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '10
 Karen
 Recursion, Recurrence relation, Master Theorem, recursion tree

Click to edit the document details