Documente Academic
Documente Profesional
Documente Cultură
10n2 - 3n = Q(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= Q(n2)
asymp - 5 Comp 122
Example
Q(g(n)) = {f(n) : positive constants c1, c2, and n0,
such that n n0, 0 c1g(n) f(n) c2g(n)}
Is 3n3 Q(n4) ??
How about 22n Q(2n)??
f (n) = O(g(n)) a b
f (n) = W(g(n)) a b
f (n) = Q(g(n)) a = b
f (n) = o(g(n)) a < b
f (n) = w (g(n)) a > b
Reflexivity
f(n) = Q(f(n))
f(n) = O(f(n))
f(n) = W(f(n))
Complementarity
f(n) = O(g(n)) iff g(n) = W(f(n))
f(n) = o(g(n)) iff g(n) = w((f(n))
n b o( a n )
lg(n!) = Q(n lg n)
Prove using Stirling’s approximation (in the text) for lg(n!).
A B
5n2 + 100n 3n2 + 2 A Q(B)
1 -2 2 2
asymp - 30 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
x 1
1
For |x| < 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 m1
How?
n n
1 dx
k 2 k
x
ln n
1
n
1
ln n 1
k 1 k