Docsity

Algorithm Design and Analysis | Divide and Conquer - Lecture Slides | CSE 565, Study notes of Computer Science

Toggle sidebar
bg1
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
1
1
1
2
x
xx
−
=+++
for |x| < 1
1
1
1
1
2
x
x
xxx
n
n
−
−
=++++
+
for x≠1
Return to last
slide viewed.

    
    
    
ν
    
  
ν
    ! 
" #  $ Θ%
&
' 
()* + %'
,  -    . 
 #
   
/ ,  
*   ) 0$ 
1
pf3

Partial preview of the text

Download Algorithm Design and Analysis | Divide and Conquer - Lecture Slides | CSE 565 and more Study notes Computer Science in PDF only on Docsity!

9/26/2007 (^) S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne

Sofya Raskhodnikova

Algorithm Design and Analysis

LECTURE 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 ) = 8 T ( 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

log n

= n

log 8

= n

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)

Total = cn(1+4+

+…+n

= Θ( n^3 )

cn

c( n /2)

geometric series

cn

4cn

16cn

9/26/2007 (^) S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne

Appendix: geometric series

x

x x

+ + + = for | x | < 1

x

x

x x x

n

n

 for x ≠ 1

Return to last slide viewed.

ν                          ν               !    

 #      

           

ν *  /      1  4     

ν *  /      1  4      ν  $ /        

ν *  /      1  4      ν  $ /         ν   /         ν 5  6  

  # Θ% &'

             8δ

δ 9 %(&&('

             8δ ν +     /        δ   1

δ

δ 9 %(&&('