

















































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


















































September 12, 2005^
Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson
L2.
Asymptotic Notation •^ O -,^ Ω-, and
Θ-notation Recurrences • Substitution method• Iterating the recurrence• Recursion tree• Master method Prof. Erik Demaine
September 12, 2005^
Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson
L2.
f ( n ) =^ O ( g
( n )) if there exist constants
c^ > 0,^ n^0
0 such that 0^ ≤^ f (
n )^ ≤^ cg ( n ) for all
n^ ≥^ n.^0 We write^
f ( n ) =^ O ( g
( n )) if there exist constants
c^ > 0,^ n^0
0 such that 0^ ≤^ f (
n )^ ≤^ cg ( n ) for all
n^ ≥^ n.^0
September 12, 2005^
Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson
L2.
f ( n ) =^ O ( g
( n )) if there exist constants
c^ > 0,^ n^0
0 such that 0^ ≤^ f (
n )^ ≤^ cg ( n ) for all
n^ ≥^ n.^0 We write^
f ( n ) =^ O ( g
( n )) if there exist constants
c^ > 0,^ n^0
0 such that 0^ ≤^ f (
n )^ ≤^ cg ( n ) for all
n^ ≥^ n.^0
EXAMPLE^ :
(^2) 2 n =^ O ( (^3) n )^ ( c^ = 1,
n = 2)^0 functions,not values
September 12, 2005^
Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson
L2.
f ( n ) =^ O ( g
( n )) if there exist constants
c^ > 0,^ n^0
0 such that 0^ ≤^ f (
n )^ ≤^ cg ( n ) for all
n^ ≥^ n.^0 We write^
f ( n ) =^ O ( g
( n )) if there exist constants
c^ > 0,^ n^0
0 such that 0^ ≤^ f (
n )^ ≤^ cg ( n ) for all
n^ ≥^ n.^0
EXAMPLE^ :
(^2) 2 n =^ O ( (^3) n )^ ( c^ = 1,
n = 2)^0 functions,not values
funny, “one-way”equality
September 12, 2005^
Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson
L2.
f ( n ) : there exist constants^ c^ > 0,
n > 0 such^0 that 0 ≤^ f ( n )^ ≤^ cg
( n ) for all^ n^ ≥
n }^0 O ( g ( n )) = {
f ( n ) : there exist constants^ c^ > 0,
n > 0 such^0 that 0 ≤^ f ( n )^ ≤^ cg
( n ) for all^ n^ ≥
n }^0 EXAMPLE^ :
(^2) 2 n ∈^ O ( (^3) n )
September 12, 2005^
Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson
L2.
f ( n ) : there exist constants^ c^ > 0,
n > 0 such^0 that 0 ≤^ f ( n )^ ≤^ cg
( n ) for all^ n^ ≥
n }^0 O ( g ( n )) = {
f ( n ) : there exist constants^ c^ > 0,
n > 0 such^0 that 0 ≤^ f ( n )^ ≤^ cg
( n ) for all^ n^ ≥
n }^0 EXAMPLE^ :
(^2) 2 n ∈^ O ( (^3) n ) ( Logicians:
(^2) λ n .2 n ∈
(^3) O (λ n. n ), but it’s
convenient to be sloppy, as long as weunderstand what’s
really^ going on.)
September 12, 2005^
Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson
L2.
(^3) ) = n +^ O (^2) ( n ) means^3 f ( n ) =^ n +
h ( n ) for some^ h
( n )^ ∈^ O ( n
September 12, 2005^
Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson
L2.
+^ O ( n ) =^
(^2) O ( n ) means for any^ f ( n
)^ ∈^ O ( n ): (^2) n + f ( n ) =^ h ( n ) for some^ h ( n )^ ∈
(^2) O ( n ).
September 12, 2005^
Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson
L2.
upper-bound
notation. It
makes no sense to say
f ( n ) is at least
(^2) O ( n ).
Ω( g ( n )) = {
f ( n ) : there exist constants^ c^ > 0,
n > 0 such^0 that 0 ≤^ cg ( n )^ ≤
f ( n ) for all^ n^ ≥
n }^0 Ω( g ( n )) = {
f ( n ) : there exist constants^ c^ > 0,
n > 0 such^0 that 0 ≤^ cg ( n )^ ≤
f ( n ) for all^ n^ ≥
n }^0
September 12, 2005^
Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson
L2.
upper-bound
notation. It
makes no sense to say
f ( n ) is at least
(^2) O ( n ).
Ω( g ( n )) = {
f ( n ) : there exist constants^ c^ > 0,
n > 0 such^0 that 0 ≤^ cg ( n )^ ≤
f ( n ) for all^ n^ ≥
n }^0 Ω( g ( n )) = {
f ( n ) : there exist constants^ c^ > 0,
n > 0 such^0 that 0 ≤^ cg ( n )^ ≤
f ( n ) for all^ n^ ≥
n }^0
EXAMPLE^ :
( c^ = 1,^ n^0
)(lg n n^ Ω=
September 12, 2005^
Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson
L2.
g ( n ))^ ∩ Ω
( g ( n )) Θ( g ( n )) = O(
g ( n ))^ ∩ Ω
( g ( n )) )( (^221 2) nnn Θ=− 2 EXAMPLE^ :
September 12, 2005^
Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson
L2.
O -notation and
Ω-notation are like
≤^ and^ ≥.
o -notation and
ω-notation are like < and >.
f ( n ) : for any constant
c^ > 0, there is a constant
n > 0^0 such that 0
≤^ f ( n )^ <^ cg
( n ) for all^ n^ ≥
n }^0
f ( n ) : for any constant
c^ > 0, there is a constant
n > 0^0 such that 0
≤^ f ( n )^ <^ cg
( n ) for all^ n^ ≥
n }^0 EXAMPLE^ :
( n = 2/ c )^0 (^2 32) n =^ o ( n
September 12, 2005^
Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson
L2.
Lecture 1
required us to solve a recurrence. • Recurrences are like solving integrals,differential equations, etc.^ o^ Learn a few tricks. • Lecture 3 : Applications of recurrences todivide-and-conquer algorithms.
September 12, 2005^
Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson
L2.