You are on page 1of 3

GkCW1n CI IUNC1ICNS

ln Lhe growLh of luncLlons we can flnd ouL Lhe complexlLy of an algorlLhm ln Lerms of 1lme Space
ASYMPTOTIC NOTATIONS:
Suppose we are considering two algorithm say A & B , for solving problem. Let us say that
we've done a analysis of the running times of each of the algorithm and determined them to be
T
a
(n) and T
b
(n).
T
a
(n) Time taken by algorithm A
T
b
(n) Time taken by algorithm B
n measure of problem size.
Then it should be a fairly simple matter to compare the function T
a
(n) and T
b
(n) to determine
which algorithm is best.
But it is really simple? What does it mean for one function, say T
a
(n) to be better than another
function, T
b
(n)?
One possibility arises iI we know the problem size a priori(without examination). E.g., suppose
the problem size is n
0
and T
a
(n
0
) T
b
(n
0
). Then clearly algorithm A is better than algorithm B Ior
problem size n
0
.
In the general case, we have no a priori knowledge oI the problem size. However, iI it can be
shown, say, that Ior all n~0 : T
a
(n) T
b
(n) , then algorithm A is better than algorithm B
regardless oI the problem size.
UnIortunately, we usually don't know the problem size beIorehand, nor is it true that one oI the
Iunctions is less than or equal the other over the entire range oI problem sizes.
In this case, we consider the asymptotic behavior oI the two Iunctions Ior very large problem
sizes.
There are some most usable notations Iro Iinding the time complexity oI an algorithm are as
Iollows:
1| Big oh(O) notation :
Consider a Iunction 1(n) which is non-negative Ior all integers n~0. We say that ``1(n) is big oh
g(n),'' which we write 1(n)O(g(n)), iI there exists an integer n
0
and a constant c~0 such that Ior
all integers n~n
0
,
1(n)C.g(n)

GkCW1n CI IUNC1ICNS

example:
I(n)3n5
solution 3n5 C.n
N1 : 3.15C.1
C8 Ior all n~1
So, f(n)Og(n)

| Big Omega(O) notation:
For non-negative Iunctions, 1(n) and g(n), iI there exists an integer n
0
and a constant c ~ 0 such
that Ior all integers n ~ n
0
, 1(n) _ cg(n), then 1(n) is omega oI g(n). This is denoted as
f(n) D(g(n))
example:
I(n)3n5
solution 3n5 3.n
N1 : 3.153.1
C3 Ior all n~1
So, f(n)Og(n)

3| Big Theta(O) notation:
For non-negative Iunctions, 1(n) and g(n), 1(n) is theta oI g(n) iI and only iI 1(n) O(g(n))
and 1(n) O(g(n)). This is denoted as

f(n) O(g(n))
This is basically saying that the Iunction, 1(n) is bounded both Irom the top and bottom by the
same Iunction, g(n).
GkCW1n CI IUNC1ICNS
C
1
.g(n)I(n)C

.g(n)


example:
I(n)3n5
solution
C
1
.g(n)I(n)C

.g(n)
Taking Iirst part oI the equation :
C
1
.g(n)I(n
3n5 3.n
N1 : 3.153.1
C3 Ior all n~1
Taking second part oI the equation :
I(n)C

.g(n)
3n5 C.n
N1 : 3.15C.1
C8 Ior all n~1
So, Ior all n~1 , C
1
3 and C

8
So f(n)O(n)

You might also like