Professional Documents
Culture Documents
T n
5.1
The O notation
( ) the set of fun
tions ( ) for whi
h ( ) ( ) for all positive integers,
, and
O g n
f n
>
< g n
n > N
f n
g n
O g
O g
f n
f n
g n
n > N
( ) =
( ) \ ( )
g
O g
We
an derive:
f
2 (g )
if
()
lim
!1 ( ) =
Thus,
( ) is a lower bound - fun
tions in
( ) grow faster than and ( )
are fun
tions that grow at the same rate as . In these last two statements as in most of the dis
ussion on
omplexity theory - "within a
onstant fa
tor"
is understood. Dierent languages,
ompilers, ma
hines, operating systems, et
will produ
e dierent
onstant fa
tors: it is the general behaviour of the running
time as in
reases to very large values that we're
on
erned with.
f n
g n
5.2
an
bn
an
bn
b >
exp n
b >
;k >
0:5
2n
b n
;k
gr
fh
b; d >
th
e.g.
(
(n+1)n
is
2
k is
r +1
k=1
n
k=1
( ))
2
th
5.3
A problem is said to be intra
table if no algorithm with polynomial time
omplexity is known for it. We will brie
y examine some intra
table problems in a
later se
tion.
5.4
Analysing an algorithm
First note that a sequen
e of statements whi
h is exe
uted on
e only is O(1).
It doesn't matter how many statements are in the sequen
e - only that the
number of statements (or the time that they take to exe
ute) is
onstant for all
problems.
2n
2n
for(j=0;j<n;j++)
for(i=0;i<j;i++)
{ s; }
..
n n
Then
2n