0% found this document useful (0 votes)
70 views10 pages

Asymptotic Analysis and Time Complexity: Analysis of Algorithm Lecture # 2 Mariha Asad

This document discusses asymptotic analysis and time complexity analysis of algorithms. It provides examples of using Big-O, Big-Omega, and Big-Theta notations to find the upper bound, lower bound, and tight bound of functions. Functions like f(n)=2n+3, f(n)=2n^2+3n+4, and f(n)=n! are analyzed to demonstrate calculating their asymptotic bounds. The key points covered are the definitions of Big-O, Big-Omega, and Big-Theta notations and how to determine the asymptotic classification of functions based on positive constants and exponents of n.

Uploaded by

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

Asymptotic Analysis and Time Complexity: Analysis of Algorithm Lecture # 2 Mariha Asad

This document discusses asymptotic analysis and time complexity analysis of algorithms. It provides examples of using Big-O, Big-Omega, and Big-Theta notations to find the upper bound, lower bound, and tight bound of functions. Functions like f(n)=2n+3, f(n)=2n^2+3n+4, and f(n)=n! are analyzed to demonstrate calculating their asymptotic bounds. The key points covered are the definitions of Big-O, Big-Omega, and Big-Theta notations and how to determine the asymptotic classification of functions based on positive constants and exponents of n.

Uploaded by

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

Asymptotic Analysis and

Time Complexity
Analysis of Algorithm
Lecture # 2
Mariha Asad
Big-Oh (O)
Example 1: Let a function f(n) = 2n+3, find out the upper bound of this
function
f(n) =O( g(n) )if there exist a positive constants c and n0 such that
0 ≤ f(n) ≤ c g(n) for all n ≥ n0
2n+3 ≤ 9* n2
n ≥1 f(n) = O(n)
f(n) = O(n2)
2n+3 ≤ 5n 2n + 3 ≤ 10 * n for all n ≥1 f(n) = O(n3)
f(n) = O(logn)
c = 10 , g(n) = n
So f(n) = O(n)
Big-Omega(Ω)
Example : Let a function f(n) = 2n+3, find out the lower bound of this
function
f(n) = Ω(g(n)) if there exist positive constants c and n0 such that
0 ≤ c g(n) ≤ f(n) for all n ≥ n0
2n +3 ≥ 5* n
2n +3 ≥ 1* n for all n ≥1 f(n) = Ω(n)
n=2; 4+ 3 ≥ 2*2 c = 1 , g(n) = n f(n) = Ω(logn)
n=3; 6+3 ≥ 2*3 f(n) = Ω(n2)
n=4; 8+3 ≥ 2*4 So f(n) = Ω(n)
Big-Theta (θ)
Example : Let a function f(n) = 2n+3, find out the tight bound of this
function
f(n) = θ(g(n)) if there exist positive constants c1,c2 and n0 such that
0 ≤ c1 g(n) ≤ f(n) ≤ c2 g(n) for all n ≥ n0
1 * n ≤ 2n + 3 ≤ 10 * n for all n ≥ 1 We cannot use any other
When c1 = 1, c2 = 10, g(n) = n thing except n here
f(n) = θ(n)
So f(n) = θ(n) f(n) = θ(n2)
Example 2
Let a function f(n) = 2n2 + 3n + 4 find out upper, lower and tight bound
of it
For Big-Oh (O)
2n2 + 3n + 4 ≤ 2n2 + 3n2 + 4n2
2n2 + 3n + 4 ≤ 9 n2 for all n ≥ 1
c = 9 , g(n)= n2
So f(n) = O(n2)
Example 2
For Big-Omega (Ω):
2n2 + 3n + 4 ≥ 1 * n2 for all n ≥ 1
c=1, g(n) = n2
So f(n) = Ω(n2)
For Big-Theta (θ) :
1 * n2 ≤ 2n2 + 3n + 4 ≤ 9 * n2 for all n ≥ 1
When c1 = 1, c2=2, g(n) = n2
So f(n)= θ(n2 )
Example 3
Let a function f(n) = n2logn + n find out upper, lower and tight bound of
it
1 * n2 logn ≤ n2logn + n ≤ 10 n2 logn for all n ≥ 1
When c1= 1, c2 =10, g(n) = n2 logn
So f(n)= θ(n2 logn )
f(n)= o(n2 logn)
f(n) = Ω(n2 logn)
Example 4
f(n) = n!
1 ≤ n! ≤ n*n*n*…*n for all n ≥ 1
1 ≤ 1*2*3*4*….*n ≤ n*n*n*…*n
1 ≤ n! ≤ nn
When c1= 1, c2 =1, g(n) = ? We are not getting a
single value of g(n) so
So f(n)= O(nn) we cannot find θ

f(n) = Ω(1)
Example 5
f(n) = logn!
1 ≤ logn! ≤ log(n*n*n*…*n) for all n ≥ 1
1 ≤ log(1*2*3*4*….*n) ≤ log(n*n*n*…*n)
Lognn = nlogn
1 ≤ log n! ≤ lognn

Log 8 = 3 When c1= 1, c2 =1, g(n) = ?


So f(n)= O(lognn) which O(n logn)
f(n) = Ω(1)
Thanks

You might also like