You are on page 1of 2

Introduction to Algorithms, Spring 2010

Homework 1 solutions
March 18, 2010

4.2-1, page 82.


P1 = 1 (8 2) = 6

P2 = (1 + 3) 2 = 8

P3 = (7 + 5) 6 = 72

P4 = 5 (4 6) = 10

P5 = (1 + 5)(6 + 2) = 48

P6 = (3 5)(4 + 2) = 12

P7 = (1 7)(6 + 8) = 84

r = 48 + (10) + 8 + (12) = 18
s = 6 + 8 = 14
t = 72 + (10) = 62

u = 48 + 6 72 (84) = 66


 

1 3
6 8
18 14

=
7 5
4 2
62 66

4.5-1, c, d page 96.


c. T (n) = (n), since 2n/4 0.5n for all sufficiently large n.
d. T (n) = (n2 ), since 2n2 /16 0.125n2 for all sufficiently large n.

Problem 4-1, e, f, g page 107.


e. T (n) = (nlog2 7 ) by master theorem case 1.
p
f. T (n) = ( n lg n) by master theorem case 2.
g. Guess T (n) = (n3 ) and verify it by using substitution method. Prove T (n) cn3 for
some c > 0 and T (n) dn3 for some d > 0.
1

Problem 4-3, f, j page 108.


f. T (n) = (n), by recursion-tree method. Hint: for 0 < r < 1,

i=1

ri =

1
.
1r
k

j. T (n) = (n lg lg n), by recursion-tree method. Hint: for c > 1, if n = c 2 then


k = lg logc n

You might also like