0% found this document useful (0 votes)
1 views

Asymptotic Hand Out

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

Asymptotic Hand Out

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Asymptotic Notation: Definitions and Examples

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. If A = 0, then f (n) = O(g(n)), and f (n) 6= Θ(g(n)).

2. If A = ∞, then f (n) = Ω(g(n)), and f (n) 6= Θ(g(n)).

3. If A 6= 0 is finite, then f (n) = Θ(g(n)).

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.

Theorem 2: l’Hopital’s Rule


Let f (x) and g(x) be differentiable functions. If lim f (x) = lim g(x) = 0 or lim f (x) = lim g(x) = ∞,
x→∞ x→∞ x→∞ x→∞
then
f (x) 0
f (x)
lim = lim 0
x→∞ g(x) x→∞ g (x)

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

0 ≤ f (n) ≤ c2 g(n) for all n ≥ n00

Similarly, if g(x) = O(f (x)), then there are positive constants c01 and n000 such that

0 ≤ g(n) ≤ c01 f (n) for all n ≥ n000 .

We can divide this by c01 to obtain


1
0≤ g(n) ≤ f (n) for all n ≥ n000 .
c01

Setting c1 = 1/c01 and n0 = max(n00 , n000 ), we have

0 ≤ c1 g(n) ≤ f (n) ≤ c2 g(n) for all n ≥ n0 .

Thus, f (x) = Θ(g(x)).

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

0 ≤ f (n) ≤ c1 g(n) for all n ≥ n00 ,

and if g(x) = O(h(x)), then there are positive constants c2 and n000 such that

0 ≤ g(n) ≤ c2 h(n) for all n ≥ n000 .

Set n0 = max(n00 , n000 ) and c3 = c1 c2 . Then

0 ≤ f (n) ≤ c1 g(n) ≤ c1 c2 h(n) = c3 h(n) for all n ≥ n0 .

Thus f (x) = O(h(x)).

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,

x8 + 7x7 − 10x5 − 2x4 + 3x2 − 17 ≤ x8 + 7x7 + 3x2 .

• We can upper bound any function by removing the lower order terms with negative coefficients, as long
as x > 0.

Next, it is not hard to see that when x ≥ 1,

x8 + 7x7 + 3x2 ≤ x8 + 7x8 + 3x8 = 11x8 .

• 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,

x8 + 7x7 − 10x5 − 2x4 + 3x2 − 17 ≥ x8 − 10x5 − 2x4 − 17.

• We can lower bound any function by removing the lower order terms with positive coefficients, as long
as x > 0.

Next, we can see that when x ≥ 1,

x8 − 10x5 − 2x4 − 17 ≥ x8 − 10x7 − 2x7 − 17x7 = x8 − 29x7 .

• 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

x8 + 7x7 − 10x5 − 2x4 + 3x2 − 17 x8 7x7 10x5 2x4 3x2 17


lim = lim + 8 − 8 − 8 + 8 − 8
x→∞ x8 x→∞ x8 x x x x x
7 10 2 3 17
= lim 1 + − 3 − 4 + 6 − 8
x→∞ x x x x x
= lim 1 + 0 − 0 − 0 + 0 − 0 = 1
x→∞

Thus, f (x) = Θ(x8 ) by the Theorem.

4. Find a tight bound on f (x) = x4 − 23x3 + 12x2 + 15x − 21.

Solution #1
It is clear that when x ≥ 1,

x4 − 23x3 + 12x2 + 15x − 21 ≤ x4 + 12x2 + 15x ≤ x4 + 12x4 + 15x4 = 28x4 .

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

x4 23x3 12x2 15x 21


lim x4 − 23x3 + 12x2 + 15x − 21 = lim − 4 + 4 + 4 − 4
x→∞ x→∞ x4 x x x x
23 12 15 21
= lim 1 − + 2+ 3− 4
x→∞ x x x x
= lim 1 − 0 + 0 + 0 − 0 = 1
x→∞

5. Show that log x = O(x).


Proof:

1
log x 1
lim = lim x = lim =0
x→∞ x x→∞ 1 x→∞ x

Therefore, log n = O(n).

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.)

7. Show that log n! = O(n log n)


Proof:
In the previous problem, we showed that when n ≥ 1, n! ≤ nn . Notice that n! ≥ 1, so taking logs of both
sides, we obtain 0 ≤ log n! ≤ log nn = n log n for all n ≥ 1. Therefore log n! = O(n log n). (Here,
n0 = 1, and c = 1.)

8. Find a good upper bound on n log(n2 + 1) + n2 log n.


Solution:
If n > 1,

log(n2 + 1) ≤ log(n2 + n2 ) = log(2n2 ) = (log 2 + log n2 ) ≤ (log n + 2 log n) = 3 log n

Thus when n > 1,

0 ≤ n log(n2 + 1) + n2 log n ≤ n3 log n + n2 log n ≤ 3n2 log n + n2 log n ≤ 4n2 log n.

Thus, n log(n2 + 1) + n2 log n = O(n2 log n).

√ √
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).

10. Show that 2x = O(3x ).


Proof #1: µ ¶x
2x 2
This is easy to see since lim x = lim = lim 0.
x→∞ 3 x→∞ 3 x→∞

Proof #2:
If x ≥ 1, then clearly (3/2)x ≥ 1, so
µ ¶x µ ¶x
3 2×3
2x ≤ 2x = = 3x .
2 2

You might also like