
1
9/26/2007
S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne
Sofya Raskhodnikova
Algorithm Design and Analysis
L
ECTURE 13
Divide and Conquer
•Closest Pair of Points
9/26/2007
S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne
Review questions
•Guess the solution to the recurrence:
T(n)=8T(n/2)+cn.
(Answer: Θ(n
3
).)
•Draw the recursion tree for this recurrence.
a. What is its height?
(Answer: h=log n.)
b. What is the number of leaves in the tree?
(Answer: 8
h
= 8log n= nlog 8= n
3
.)
9/26/2007
S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne
Review questions: recursion tree
Solve T(n)=8T(n/2)+cn:
c(n/4) c(n/4) c(n/4) (n/4)
c(n/2)
Θ(1)
…
…
Total = cn(1+4+4
2
+4
3
+…+n
2
)
= Θ(n
3
)
cn
c(n/2)
geometric series
8
cn
88
4cn
16cn
9/26/2007
S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne
Appendix: geometric series
2
xx
=+++
for |x| < 1
1
2
x
xxx
n
−
=++++
for x≠1
Return to last
slide viewed.
ν
ν
!
" # $ Θ%
&
'
()* + %'
, - .
#
/ ,
* ) 0$
1