Sie sind auf Seite 1von 3

---------------------------- 3 ---------------------------- 3-2

Growth of Functions f(n) = (g(n)) iff g(n)=(f(n)), Ex. n2=(3n2-6n)

3.1 Asymptotic notation O-notation: f(n) = O(g(n))


g(n) is an asymptotically upper bound for f(n).
-notation: f(n) = (g(n))
g(n) is an asymptotically tight bound for f(n). O(g(n))= {f(n)| there exist positive constants c
and n0 such that
(g(n)) = {f(n)| there exist positive constants c1, 0 f(n)cg(n)
c2, and n0 such that for all n n0}
0 c1 g(n)f(n)c2 g(n)
for all n n0}
(g(n)) O(g(n))
Example: Prove that 3n2 - 6n = (n2). f(n) = (g(n)) implies f(n) = O(g(n))
Proof: To do so, we have to determine c1, c2, and 6n = O(n), 6n = O(n2)
n0 such that "The running time is O(n2)" means "the worst-
case running time is O(n2)."
c1n2 3n2 - 6n c2n2, (for all nn0)
-notation: f(n) = (g(n))
g(n) is an asymptotically lower bound for f(n).
dividing which by n2 yields
(g(n))= {f(n)| there exists positive constants c
c1 3 - 6/n c2. and n0 such that
0 cg(n) f(n)
Clearly, by choosing c1=2, c2=3 and n0=6 we can for all n n0}
verify that 3n2 - 6n = (n2). Q.E.D
3-3 3-4
f(n) = (g(n)) iff (f(n)=O(g(n))) & (f(n)=(g(n))) -notation: f(n) = (g(n)) (little-omega of g of n)

(g(n)) = {f(n)| for any positive constant c, there


exists a constant n0 > 0 such that
0 cg(n) < f(n) for all n n0}

2n2 = (n), but 2n2 (n2).


f (n )
f(n) = (g(n)) iff lim = .
tight bound upper bound lower bound n g ( n )
Comparison of functions

functions: O
o-notation: f(n) = o(g(n)) (little-oh of g of n) real numbers:

o(g(n))= {f(n)| for any positive constant c, there
Transitivity, Reflexivity, Symmetry
exists a constant n0 > 0 such that

0 f(n) < cg(n) Any two real numbers can be compared.
for all n n0} (trichotomy) But, not any two functions can be
compared.
2n = o(n2), but 2n2 o(n2).
f(n) = o(g(n)) can also be defined as Example: f(n)=n and g(n)=n1+sin n
f (n )
lim = 0.
n g ( n ) Homework: Problems 3-2, 3-3, 3-4.
3-5
Appendix A: Summation formulas

n n n
(cak bk ) c ak bk
k 1 k 1 k 1

n 1 n
2 n(n 1) (n 2 )
k x k ( x n 1 1) /( x 1)
k 1 k 0

n 1
Hn k log e n O(1) (Harmonic series)
k 1

1 x
x k
1 x
( x 1) kx k (1 x )2
( x 1)
k 0 k 0

n 1 1 n 1 1 1 1
( ) 1
k 1 k ( k 1) k 1 k k 1 n

n n
lg ak lg ak
k 1 k 1

Das könnte Ihnen auch gefallen