Asymptotic Hand Out
Asymptotic Hand Out
Chuck Cusack
Definitions
Let f be a nonnegative function. Then we define the three most common asymptotic bounds as follows.
• We say that f (n) is Big-O of g(n), written as f (n) = O(g(n)), iff there are positive constants c and n0 such
that
0 ≤ f (n) ≤ c g(n) for all n ≥ n0
If f (n) = O(g(n)), we say that g(n) is an upper bound on f (n).
• We say that f (n) is Big-Omega of g(n), written as f (n) = Ω(g(n)), iff there are positive constants c and
n0 such that
0 ≤ c g(n) ≤ f (n) for all n ≥ n0
If f (n) = Ω(g(n)), we say that g(n) is a lower bound on f (n).
• We say that f (n) is Big-Theta of g(n), written as f (n) = Θ(g(n)), iff there are positive constants c1 , c2
and n0 such that
0 ≤ c1 g(n) ≤ f (n) ≤ c2 g(n) for all n ≥ n0
Equivalently, f (n) = Θ(g(n)) if and only if f (n) = O(g(n)) and f (n) = Ω(g(n)). If f (n) = Θ(g(n)),
we say that g(n) is a tight bound on f (n).
Note: Sometimes the notation f (n) ∈ O(g(n)) is used instead of f (n) = O(g(n)) (similar for Ω and Θ). These
mean essentially the same thing, and the use of either is generally personal preference.
Proving Bounds
There are two common ways of proving bounds. The first is according to the definitions above. The second, and
much easier approach, uses the following theorem.
Theorem 1
Let f (n) and g(n) be functions such that
f (n)
lim = A.
n→∞ g(n)
Then
1
Notice that if the above limit does not exist, then the first technique should be used. Luckily, in the analysis of
algorithms the above approach works most of the time.
Now is probably a good time to recall a very useful theorem for computing limits, called l’Hopital’s Rule.
Examples
We present several examples of proving theorems about asymtotic bounds and proving bounds on several different
functions.
1. Prove that if f (x) = O(g(x)), and g(x) = O(f (x)), then f (x) = Θ(g(x)).
Proof:
If f (x) = O(g(x)), then there are positive constants c2 and n00 such that
Similarly, if g(x) = O(f (x)), then there are positive constants c01 and n000 such that
2. Let f (x) = O(g(x)) and g(x) = O(h(x)). Show that f (x) = O(h(x)).
Proof:
If f (x) = O(g(x)), then there are positive constants c1 and n00 such that
and if g(x) = O(h(x)), then there are positive constants c2 and n000 such that
2
3. Find a tight bound on f (x) = x8 + 7x7 − 10x5 − 2x4 + 3x2 − 17.
Solution #1
We will prove that f (x) = Θ(x8 ). First, we will prove an upper bound for f (x). It is clear that when x > 0,
• We can upper bound any function by removing the lower order terms with negative coefficients, as long
as x > 0.
• We can upper bound any function by replacing lower order terms with positive coefficients by the
dominating term with the same coefficients. Here, we must make sure that the dominating term is
larger than the given term for all values of x larger than some threshold x0 , and we must make note of
the threshold value x0 .
Thus, we have
f (x) = x8 + 7x7 − 10x5 − 2x4 + 3x2 − 17 ≤ 11x8 for all x ≥ 1,
and we have proved that f (x) = O(x8 ).
Now, we will get a lower bound for f (x). It is not hard to see that when x ≥ 0,
• We can lower bound any function by removing the lower order terms with positive coefficients, as long
as x > 0.
• We can lower bound any function by replacing lower order terms with negative coefficients by a sub-
dominating term with the same coefficients. (By sub-dominating, I mean one which dominates all but
the dominating term.) Here, we must make sure that the sub-dominating term is larger than the given
term for all values of x larger than some threshold x0 , and we must make note of the threshold value
x0 . Making a wise choice for which sub-dominating term to use is crucial in finishing the proof.
Next, we need to find a value c > 0 such that x8 − 29x7 ≥ cx8 . Doing a little arithmetic, we see that this is
equivalent to (1 − c)x8 ≥ 29x7 . When x ≥ 1, we can divide by x7 and obtain (1 − c)x ≥ 29. Solving for c
we obtain
29
c≤1− .
x
If x ≥ 58, then c = 1/2 suffices. We have just shown that if x ≥ 58, then
1
f (x) = x8 + 7x7 − 10x5 − 2x4 + 3x2 − 17 ≥ x8 .
2
Thus, f (x) = Ω(x8 ). Since we have shown that f (x) = Ω(x8 ) and that f (x) = O(x8 ), we have shown that
f (x) = Θ(x8 ).
3
Solution #2
We guess (or know, if we read Solution #1) that f (x) = Θ(x8 ). To prove this, notice that
Solution #1
It is clear that when x ≥ 1,
Also,
1
x4 − 23x3 + 12x2 + 15x − 21 ≥ x4 − 23x3 − 21 ≥ x4 − 23x3 − 21x3 = x4 − 44x3 ≥ x4 ,
2
whenever
1 4
x ≥ 44x3 ⇔ x ≥ 88.
2
Thus
1 4
x ≤ x4 − 23x3 + 12x2 + 15x − 21 ≤ 28x4 , for all x ≥ 88.
2
We have shown that f (x) = x4 − 23x3 + 12x2 + 15x − 21 = Θ(x4 ).
Solution #2
From Solution #1 we already know that f (x) = Θ(x4 ). We verify this by noticing that
1
log x 1
lim = lim x = lim =0
x→∞ x x→∞ 1 x→∞ x
4
6. Show that n! = O(nn )
Proof:
Notice that when n ≥ 1, 0 ≤ n! = 1 · 2 · 3 · · · n ≤ n · n · · · n = nn . Therefore n! = O(nn ) (Here n0 = 1,
and c = 1.)
√ √
9. Show that ( 2)log n = O( n), where log means log2 .
Proof:
It is not too hard to see that
√ √ 1/2 1 1 √
( 2)log n = nlog 2 = nlog 2 = n 2 log 2 = n 2 = n.
√ √
Thus it is clear that ( 2)log n = O( n).
Proof #2:
If x ≥ 1, then clearly (3/2)x ≥ 1, so
µ ¶x µ ¶x
3 2×3
2x ≤ 2x = = 3x .
2 2