Title: Data Structures CSCI 262, Spring 2004 Lecture26 Asymptotic Analysis II
1Data Structures CSCI 262, Spring
2004Lecture26Asymptotic Analysis II
2Big-Oh Notation
f(n) is Say Meaning limn
f(n)/g(n) o(g(n)) little-oh of
g(n) lt 0 O(g(n)) Big-oh of g(n) lt finite Q(g
(n)) Big-theta of g(n) non-zero,
finite W(g(n)) Big-omega of g(n) gt non-zero w(g
(n)) little-omega of g(n) gt infinite
3Relationships between O,o,Q,W,w
is a subset of
w(g)
bigger growth of f
W(g)
Q(g)
smaller growth of f
O(g)
o(g)
4It follows that
if f w(g) then f W(g) if f o(g) then f
O(g) Symmetric relationships f w(g) if and
only if g o(f) f W(g) if and only if g
O(f) f Q(g) if and only if g Q(f)
5Rules For O-notation
- If f(n) is a polynomial of degree r, then f(n)
Q(nr) - If r lt s, then nr is o(ns)
- If a gt 1, bgt 1 then loga(n) is Q(logb(n))
- loga(n) is o(nr) for r gt 0, real valued a
- nr is o(an) for a gt1, real valued r
- If 0 lt a lt b then an is o(bn)
6Hints for comparing functions
- When comparing functions, first look for the
dominant term in each function. You can ignore
lower order terms. - E.g. f(n) 3lg(n) 20n n2
- Dominant term ?
- 2) It may be easier to compare the functions to a
known function to find the relative rates of
growth.
- 3) When in doubt, graph the functions. This will
give you an idea of which grows faster. (However
you must support your answer by finding the limit
of f/g).
7Examples
Compare the following pairs of functions 1.
f(n) 5n6 n2 - 2 g(n) 100 n4 - 3n2 5n
7 2. f(n) 3 log (n) g(n) n2 - 7n
2 3. f(n) 100 log(n) 1000 g(n)
log2(n) 4. f(n) n2 3n - log n g(n) 5n2
8Useful Exponential facts
an product of n copies of a
a-n 1/an
Key identities
a0 1
aman amn
(am)n amn
Examples
(22)3 ?
253/2 ?
2223 ?
9Useful logarithm facts
logba x, the power to which b must be raised to
equal a bx a
Example log28 3, because 23 8
Logarithm facts
logb(1/a) -logb(a)
logc(ab) logc(a) logc(b)
Special case logc(an) nlogc(a)
logc(1) 0
clogc(b) b logc(cb)
logc(a) logc(b) logb(a)
10Useful derivative facts
1. Derivatives of polynomials
2. Derivatives of logarithms
11More Derivative facts
3. Chain rule
Chain rule example
4. Multiplying functions
Example
12More Examples
- Compare the following functions
- f(n) lg(lg(n))
- g(n) lg(n)
- f(n) lg(n)
- g(n) n0.5
- 7) f(n) lg3(n) (lg(n))3
- g(n) n0.5