Professional Documents
Culture Documents
Suppose that f (n) > 0 and g (n) > 0 for all n n0 . Suppose that
f (n)
.
n g (n)
L = lim
Then
o(g (n))
f (n) (g (n))
(g (n))
if L = 0
if 0 < L <
if L = .
CS240 - Module 1
Spring 2014
32 / 48
An Example
Compare the growth rates of log n and ni (where i > 0 is a real number).
CS240 - Module 1
Spring 2014
33 / 48
Example
Prove that n(2 + sin n/2) is (n). Note that limn (2 + sin n/2) does
not exist.
CS240 - Module 1
Spring 2014
34 / 48
Example
Prove that n(2 + sin n/2) is (n). Note that limn (2 + sin n/2) does
not exist.
60
40
20
0
0
10
15
20
25
CS240 - Module 1
Spring 2014
34 / 48
CS240 - Module 1
Spring 2014
35 / 48
Maximum rules: Suppose that f (n) > 0 and g (n) > 0 for all n n0 .
Then:
O(f (n) + g (n)) = O(max{f (n), g (n)})
(f (n) + g (n)) = (max{f (n), g (n)})
(f (n) + g (n)) = (max{f (n), g (n)})
Transitivity: If f (n) O(g (n)) and g (n) O(h(n)) then f (n) O(h(n)).
CS240 - Module 1
Spring 2014
36 / 48