Documente Academic
Documente Profesional
Documente Cultură
Asymptotic Notation
You may be asking that we continue to use the notation but have never dened it. Lets remedy this
now. Given any Iunction gn, we dene gn to be a set oI Iunctions that asvmptoticallv equivalent
to gn. Formally:
gn n there exist positive
constants c
, c
and n
such that
0 c
gn n c
gn
Ior all n n
This is written as 'n gn That is, n and gn are asvmptoticallv equivalent. This means
that they have essentially the same growth rates Ior large n. For example, Iunctions like
4n
,
8n
2n 3,
n
,5
n 10 log n
nn 3
are all asymptotically equivalent. As n becomes large, the aominant (Iastest growing) term is some
constant times n
.
Consider the Iunction
n 8n
2n 3
Our inIormal rule oI keeping the largest term and ignoring the constant suggests that n n
. Let`s
see why this bears out Iormally. We need to show two things Ior
n 8n
2n 3
Lower bound n 8n
,
23
24
Upper bound n grows no Iaster asymptotically than n
,
Lower bound: n grows asymptotically at least as Iast as n
and n
, such that n c
Ior all n n
2n 3 8n
3 n
3 n
Thus c
3. We then have n c
Ior all n n
.
Upper bound: n grows asymptotically no Iaster than n
and n
, such that n c
Ior all n n
2n 3 8n
2n 8n
2n
10n
Thus c
1. We thus have n c
Ior all n n
.
From lower bound we have n
3. In conclusion, iI we let c
, c
10 and n
3, we have
n
8n
2n 3 10n
Ior all n
3
We have thus established
0 c
gn n c
gn Ior all n n
2n 3 does grow
at least as Iast asymptotically as n. But the upper bound is Ialse. Upper bounds requires that there exist
positive constants c
and n
such that n c
n Ior all n n
.
InIormally we know that n 8n
and n
2n 3 c
n Ior
all n n
Since this is true for all sufciently large n then it must be true in the limit as n tends to
innity. If we divide both sides by n, we have
lim
8n 2
3
n
c
.
It is easy to see that in the limit, the leIt side tends to . So, no matter how large c
Ior all
n n
is violated. (c
and n
:
lim
8
n
2
n
3
n
The leIt side tends to 0. The only way to satisIy this is to set c
0. But by hypothesis, c
is positive.
This means that n n
.
The denition of -notation relies on proving both a lower and upper asymptotic bound. Sometimes we
only interested in proving one bound or the other. The O-notation is used to state only the asymptotic
upper bounds.
Ogn n there exist positive
constants c and n
such that
0 n cgn
Ior all n n
such that
0 cgn n
Ior all n n
26
The three notations:
gn 0 c
gn n c
gn
Ogn 0 n cgn
gn 0 cgn n
Ior all n n
These denitions suggest an alternative way of showing the asymptotic behavior. We can use limits Ior
dene the asymptotic behavior. Limit rule for -notation:
lim
n
gn
c,
Ior some constant c 0 (strictly positive but not innity) then n gn. Similarly, the limit rule
Ior O-notation is
lim
n
gn
c,
Ior some constant c 0 (nonnegative but not innite) then n Ogn and limit rule Ior
-notation:
lim
n
gn
0,
(either a strictly positive constant or innity) then n gn.
Here is a list oI common asymptotic running times:
1: Constant time; can`t beat it!
log n: Inserting into a balanced binary tree; time to nd an item in a sorted array oI length n
using binary search.
n: About the Iastest that an algorithm can run.
nlog n: Best sorting algorithms.
n
: Polynomial time. These running times are acceptable when the exponent oI n is
small or n is not to large, e.g., n 1000.
2