Vous êtes sur la page 1sur 2

THEORY OF ALGORITHMS

SOLUTIONS TO THE PROBLEMS

BAOJIAN HUA

MAY 12,2004

4.1-1 Show that the solution of T (n) = T (dn/2e) + 1 is O(lg n).

Proof. By mathematical induction. Suppose


T (dn/2e) ≤ c lgdn/2e
holds for sufficiently large n and some constant c > 0, then
T (n) = T (dn/2e) + 1
≤ c lgdn/2e + 1
(n + 1)
≤ c lg +1
2
1
= c lg n + c lg(1 + )−c+1
n
≤ c lg n (for sufficiently large n and c)


4.1-6 Solve the recurrence T (n) = 2T ( n) + 1 by making a change of variables.
Your solution should be asymptotically tight. Do not worry about whether values
are integral.

Proof. Let m = lg n and S(m) = T (2m ), the result is O(lg n · lg lg n) 

4.2-1 Use a recursion tree to determine a good asymptotic upper bound on the
recurrence T (n) = 3T (bn/2c) + n. Use the substitution method to verify your
answer.

Proof. The result is Θ(nlg 3 ) and the proof is straightforward. 

4.3-1 Use the master method to give tight asymptotic bounds for the following
recurrences.
a. T (n) = 4T (n/2) + n
b. T (n) = 4T (n/2) + n2
b. T (n) = 4T (n/2) + n3
Solution.
a. T (n) = Θ(n2 )
b. T (n) = Θ(n2 lg n)
c. T (n) = Θ(n3 )

1
2 BAOJIAN HUA MAY 12,2004

4.3-2 The recurrence T (n) = 7T (n/2) + n2 describes the running time of an


algorithm A. A competing algorithm A0 has a running time of T 0 (n) = aT 0 (n/4) +
n2 . What is the largest integer value for a such that A0 is asymptotically faster
than A?
Solution. a = 48

4.3-4 Can the master method be applied to the recurrence T (n) = 4T (n/2) +
n2 lg n? Why or why not? Give an asymptotic upper bound for this recurrence.
Solution. The master method cannot be applied. Its solution is O(n2 lg2 n).


Vous aimerez peut-être aussi