Asymptotic Notation
Asymptotic notation consists of six symbols used to describe the relative growth rates of functions. These six symbols are defined in the table below.
Notation | Description | Definition |
---|
f=Θ(g) | f grows at the same rate as g | There exists a n0 and constants c1,c2>0 such that for all n>n0, c1g(n)≤∥f(n)∥≤c2g(n). |
f=O(g) | f grows no faster than g | There exists a n0 and a constant c>0 such that for all n>n0, ∥f(n)∥≤cg(n). |
f=Ω(g) | f grows at least as fast as g | There exists a n0 and a constant c>0 such that for all n>n0, cg(n)≤∥f(n)∥. |
f=o(g) | f grows slower than g | For all c>0, there exists a n0 such that for all n>n0, ∥f(n)∥≤cg(n). |
f=ω(g) | f grows faster than g | For all c>0, there exists a n0 such that for all n>n0, cg(n)≤∥f(n)∥. |
f∼g | f/g approaches 1 | limn→∞g(n)f(n)=1 |
Testing for Same Growth Rate
f(n) and g(n) have the same growth rate if
limN→∞g(N)f(N)=c,0<c<∞
if c is some constant→f(N)=Θ(g(N))
Note: No little theta exists
3 Rules
-
Additive and Multiplicative Property
If T1(n)=O(f(n)) and T2(n)=O(g(n)), then
(a) T1(n)+T2(n)=O(f(n)+g(n)) (intuitively and less formally it is O(max(f(n),g(n)))),
(b) T1(n)×T2(n)=O(f(n)×g(n)).
-
If T(n) is a polynomial of degree k, then T(n)=Θ(nk)
-
logk(n)=O(n) for any constant k
a. This means that no matter what power of k, it will not surpass O(n).
b. However: logk(n) has a faster growth rate than log(n).
Quiz
Question 1
If f(n)=O(1) and g(n)=O(n), determine if the following statements are true or false.
- f(n)=Θ(g(n))→False, constant function does not grow at the same rate as n
- f(n)=o(g(n))→True. f(n) grows at a slower rate than g(n)
- f(n)=O(g(n))→True. f(n) is bounded above by some constant multiple of g(n)
- f(n)=ω(g(n))→False. It would mean that f(n) grows faster than g(n)
Question 2
Given f(n)=10n5+5n2+30n and g(n)=3n3, determine the validity of the following:
- f(n)=O(n5)→True
- g(n)=O(n3)→True
- f(n)=Θ(g(n))→False. n5 grows faster than n3
- f(n)=Ω(g(n))→True. f(n) grows at least as fast as g(n)
- f(n)=o(g(n))→False. o(g(n)) would mean that f(n) grows slower than g(n).
- f(n)=ω(g(n))→True. f(n) grows strictly faster than g(n)