You are on page 1of 12

ASYMPTOTIC

NOTATIONS
AARTHI D,
AP / CSE
ASYMPTOTIC NOTATIONS
⦿ To analyse an algorithm’s running time by
identifying its behaviour, as the input size of
the algorithm increases.
⦿ ASYMPTOTIC NOTATIONS TO PERFORM TIME
COMPLEXITY ANALYSIS OF A PROBLEM
◼ Big – Oh Notation (O)
◼ Big – Omega Notation (Ω)
◼ Big – Theta Notation (θ)
BIG – OH NOTATION
⦿ g(n) is an asymptotically UPPER BOUND for
f(n)
⦿ f(n) Є c.g(n) for all values of n >=no if and
only if,
⦿ f(n) = Θ(g(n)) ⇒ f(n) = O(g(n))
BIG – OMEGA NOTATION
⦿ g(n) is an asymptotically LOWER BOUND for
f(n).
⦿ f(n) Є c.g(n) for all values of n >=no if and
only if,
⦿ f(n) = Θ(g(n)) ⇒ f(n) = Ω(g(n)).
BIG – THETA NOTATION
⦿ g(n) is an asymptotically TIGHT BOUND for
f(n)
⦿ f(n) Є c.g(n) for all values of n >=no if and
only if,
⦿ c2g(n) ≤ f(n) ≤ c1g(n)
MATHEMATICAL
ANALYSIS OF
NON-RECURSIVE
ALGORITHMS
FINDING MAXIMUM ELEMENT
Algorithm: Max(a[],n)
//Determines the largest element in an array
//Input: An array a[] and size n
//Output: Maximum element in an array
max a[0]
for(i 0 to n) do
if(a[i]>max) then
max a[i]
return max
FINDING UNIQUE ELEMENT
Algorithm: Unique (a[],n)
//Determines whether all the elements in an
array a[] are distinct
//Input: An array a[] and size n
//Output: if unique element, return TRUE
else, return FALSE
for(i 0 to n-2) do
for(j i+1 to n-1) do
if(a[i] == a[j]) then
return false
return true
MATRIX MULTIPLICATION
Algorithm: MatrixMult(a[],b[])
//Multiplies two square matrices of order n
//Input: Two matrices a and b of order n*n
//Output: The multiplication result of two
matrices
for(i 0 to n-1) do
for(j 0 to n-1) do
c[i][j] 0
for(k 0 to n-1) do
c[i][j] c[i][j] + a[i][k] * b[k][j]
return c
EXERCISE
1) Algorithm: Func(n)
//Input: A non-negative integer n
s 0
for(i 0 to n) do
s s + i*i
return s
Questions:
1) What does this algorithm compute?
2) Identify the basic operation
3) Calculate f(n)
4) What is the efficiency class?
EXERCISE (CONTINUED..,)
2) Algorithm: Func(a[])
//Input: An array a[0,…,n-1] of n real numbers
min a[0]
max a[0]
for(i 1 to n) do
if(a[i]<min) then
min a[i]
if(a[i]>max) then
max a[i]
return (max-min)
Questions:
1) What does this algorithm compute?
2) Identify the basic operation
3) Calculate f(n)
4) What is the efficiency class?
5) Can you improve the efficiency? How?
EXERCISE (CONTINUED..,)
3) Algorithm: Func(a[0,…,n-1][0,…,n-1])
//Input: A matrix a[0,…,n-1][0,…,n-1] of real
numbers
for(i 0 to n-2) do
for(j i+1 to n-1) do
if(a[i,j] != a[j,i]) then
return false
return true
Questions:
1) What does this algorithm compute?
2) Identify the basic operation
3) Calculate f(n)
4) What is the efficiency class?

You might also like