Beruflich Dokumente
Kultur Dokumente
Asymptotic Notation,
Notation,
Review
Review of
of Functions
Functions &
&
Summations
Summations
}
Intuitively: Set of all functions that
have the same rate of growth as g(n).
}
Technically, f(n) (g(n)).
Older usage, f(n) = (g(n)).
Ill accept either
10n2 - 3n = (n2)
What constants for n0, c1, and c2 will work?
Make c1 a little smaller than the leading
coefficient, and c2 a little bigger.
To compare orders of growth, look at the
leading term.
Exercise: Prove that n2/2-3n= (n2)
asymp - 6 Comp 122
Example
(g(n)) = {f(n) : positive constants c1, c2, and n0,
such that n n0, 0 c1g(n) f(n) c2g(n)}
Is 3n3 (n4) ??
How about 22n (2n)??
f (n) = O(g(n)) a b
f (n) = (g(n)) a b
f (n) = (g(n)) a = b
f (n) = o(g(n)) a < b
f (n) = (g(n)) a > b
Reflexivity
f(n) = (f(n))
f(n) = O(f(n))
f(n) = (f(n))
Complementarity
f(n) = O(g(n)) iff g(n) = (f(n))
f(n) = o(g(n)) iff g(n) = ((f(n))
n b o( a n )
lg lg a = lg (lg a) 1
log b a
log a b
a logb c c logb a
asymp - 26 Comp 122
Logarithms and exponentials Bases
If the base of a logarithm is changed from one
constant to another, the value is altered by a
constant factor.
Ex: log10 n * log210 = log2 n.
Base of logarithm is not an issue in asymptotic
notation.
Exponentials with different bases differ by a
exponential factor (not a constant factor).
Ex: 2n = (2/3)n*3n.
lg(n!) = (n lg n)
Prove using Stirlings approximation (in the text) for lg(n!).
A B
5n2 + 100n 3n2 + 2 A (B)
1 -2 2 2
asymp - 31 Comp 122
Review on Summations
MaxSubvector(A, n)
maxsum 0;
for i 1 to n
do for j = i to n
sum 0
for k i to j
do sum += A[k]
maxsum max(sum, maxsum)
return maxsum
n n j
T(n) = 1
i=1 j=i k=i
1 b a 1
i a
i 1
i 3
13
2 3
n 3
4
n 1
n
x 1
k 0
x 1 x x x
k 2 n
x 1
For |x| < 1,
1
k 0
x
k
1 x
n 1 n2
n
(n 1)c nc c
i 1
ic c 2c nc
i 2 n
( c 1) 2
a
k 1
k ak 1 an a0
1 x 2
f ( x)dx f (k ) f ( x)dx
m1 k m m
f ( x)dx f (k ) f ( x)dx
m k m m 1
How?
n n
1 dx
k 2 k
x
ln n
1
n
1
ln n 1
k 1 k