Asymptotic Notations
Asymptotic Notations
CS KTU Lectures
Asymptotic Notations
• It is the mathematical notations to represent
frequency count.
• 5 types of asymptotic notations
• Big Oh (O)
• Omega (Ω)
• Theta (Ɵ)
• Little Oh (o)
• Little Omega (ω)
CS KTU Lectures
Big Oh (O) Notation
Definition:
The function f(n) = O(g(n)) iff there exists 2
positive constants c and n0 such that
0 ≤ f(n) ≤ c g(n) for all n ≥ n0
CS KTU Lectures
Big Oh (O) Notation
• It is the measure of longest amount of time
taken by an algorithm(Worst case).
• It is asymptotically tight upper bound
• O(1) : Computational time is constant
• O(n) : Computational time is linear
• O(n2) : Computational time is quadratic
• O(n3) : Computational time is cubic
• O(2n) : Computational time is exponential
CS KTU Lectures
Find the O notation of the following function
f(n) = 3n + 2
CS KTU Lectures
Find the O notation of the following function
f(n) = 3n + 2
CS KTU Lectures
Find the O notation of the following function
f(n) = 3n + 2
CS KTU Lectures
Find the O notation of the following function
f(n) = 3n + 2
CS KTU Lectures
Find the O notation of the following function
3n + 2 ≤ 4 n
CS KTU Lectures
Find the O notation of the following function
3n + 2 ≤ 4 n
CS KTU Lectures
Find the O notation of the following function
3n + 2 ≤ 4 n
CS KTU Lectures
Find the O notation of the following function
3n + 2 ≤ 4 n
CS KTU Lectures
Find the O notation of the following function
3n + 2 ≤ 4 n
CS KTU Lectures
Find the O notation of the following function
f(n) = 3n + 2
CS KTU Lectures
Find the O notation of the following function
f(n) = 3n + 2
CS KTU Lectures
Find the O notation of the following function
f(n) = 3n + 2
3n + 2= O(n)
CS KTU Lectures
Find the O notation of the following function
f(n) = 4n3 + 2n + 3
CS KTU Lectures
Find the O notation of the following function
f(n) = 4n3 + 2n + 3
CS KTU Lectures
Find the O notation of the following function
f(n) = 4n3 + 2n + 3
CS KTU Lectures
Find the O notation of the following function
f(n) = 4n3 + 2n + 3
CS KTU Lectures
Find the O notation of the following function
4n3 + 2n + 3 ≤ 5 n3
CS KTU Lectures
Find the O notation of the following function
4n3 + 2n + 3 ≤ 5 n3
CS KTU Lectures
Find the O notation of the following function
4n3 + 2n + 3 ≤ 5 n3
CS KTU Lectures
Find the O notation of the following function
4n3 + 2n + 3 ≤ 5 n3
CS KTU Lectures
Find the O notation of the following function
4n3 + 2n + 3 ≤ 5 n3
CS KTU Lectures
Find the O notation of the following function
f(n) = 4n3 + 2n + 3
CS KTU Lectures
Find the O notation of the following function
f(n) = 4n3 + 2n + 3
CS KTU Lectures
Find the O notation of the following function
f(n) = 4n3 + 2n + 3
4n3 + 2n + 3= O(n3)
CS KTU Lectures
Find the O notation of the following function
f(n) = 2n+1
CS KTU Lectures
Find the O notation of the following function
f(n) = 2n+1
CS KTU Lectures
Find the O notation of the following function
f(n) = 2n+1
CS KTU Lectures
Find the O notation of the following function
f(n) = 2n+1
CS KTU Lectures
Find the O notation of the following function
2n+1 ≤ 2 2n
CS KTU Lectures
Find the O notation of the following function
2n+1 ≤ 2 2n
CS KTU Lectures
Find the O notation of the following function
2n+1 ≤ 2 2n
CS KTU Lectures
Find the O notation of the following function
2n+1 ≤ 2 2n
CS KTU Lectures
Find the O notation of the following function
f(n) = 2n+1
CS KTU Lectures
Find the O notation of the following function
f(n) = 2n+1
CS KTU Lectures
Find the O notation of the following function
f(n) = 2n+1
2n+1 = O(2 n
)
CS KTU Lectures
Find the O notation of the following function
f(n) = 2n + 6n2 + 3n
CS KTU Lectures
Find the O notation of the following function
f(n) = 2n + 6n2 + 3n
CS KTU Lectures
Find the O notation of the following function
f(n) = 2n + 6n2 + 3n
CS KTU Lectures
Find the O notation of the following function
f(n) = 2n + 6n2 + 3n
CS KTU Lectures
Find the O notation of the following function
f(n) = 2n + 6n2 + 3n
CS KTU Lectures
Find the O notation of the following function
f(n) = 2n + 6n2 + 3n
2n + 6n2 + 3n = O(2n)
CS KTU Lectures
Is 22n = O(2n)?
CS KTU Lectures
Is 22n = O(2n)?
0 ≤ 22n ≤ c 2n for n ≥ n0
CS KTU Lectures
Is 22n = O(2n)?
0 ≤ 22n ≤ c 2n for n ≥ n0
2n 2n ≤ c 2 n
CS KTU Lectures
Is 22n = O(2n)?
0 ≤ 22n ≤ c 2n for n ≥ n0
2n 2n ≤ c 2 n
2n ≤ c
CS KTU Lectures
Is 22n = O(2n)?
0 ≤ 22n ≤ c 2n for n ≥ n0
2n 2n ≤ c 2 n
2n ≤ c for n ≥ n0
CS KTU Lectures
Is 22n = O(2n)?
0 ≤ 22n ≤ c 2n for n ≥ n0
2n 2n ≤ c 2 n
2n ≤ c for n ≥ n0
CS KTU Lectures
Is 2n+1 = O(2n)?
0 ≤ 2n+1 ≤ c 2n for n ≥ n0
CS KTU Lectures
Is 2n+1 = O(2n)?
0 ≤ 2n+1 ≤ c 2n for n ≥ n0
2x2n ≤ c 2n
CS KTU Lectures
Is 2n+1 = O(2n)?
0 ≤ 2n+1 ≤ c 2n for n ≥ n0
2x2n ≤ c 2n
2 ≤c
CS KTU Lectures
Is 2n+1 = O(2n)?
0 ≤ 2n+1 ≤ c 2n for n ≥ n0
2x2n ≤ c 2n
2 ≤c
0 ≤ 2n+1 ≤ c 2n for n ≥ n0
2x2n ≤ c 2n
2 ≤c
CS KTU Lectures
Omega (Ω) Notation
• It is the measure of smallest amount of time
taken by an algorithm(Best case)
• It is asymptotically tight lower bound
CS KTU Lectures
Find the Ω notation of the following function
f(n) = 27 n2 + 16n + 25
CS KTU Lectures
Find the Ω notation of the following function
f(n) = 27 n2 + 16n + 25
CS KTU Lectures
Find the Ω notation of the following function
f(n) = 27 n2 + 16n + 25
CS KTU Lectures
Find the Ω notation of the following function
f(n) = 27 n2 + 16n + 25
CS KTU Lectures
Find the Ω notation of the following function
27 n2 + 16n + 25 ≥ 27 n2
CS KTU Lectures
Find the Ω notation of the following function
27 n2 + 16n + 25 ≥ 27 n2
CS KTU Lectures
Find the Ω notation of the following function
27 n2 + 16n + 25 ≥ 27 n2
CS KTU Lectures
Find the Ω notation of the following function
27 n2 + 16n + 25 ≥ 27 n2
CS KTU Lectures
Find the Ω notation of the following function
f(n) = 27 n2 + 16n + 25
CS KTU Lectures
Find the Ω notation of the following function
f(n) = 27 n2 + 16n + 25
CS KTU Lectures
Find the Ω notation of the following function
f(n) = 27 n2 + 16n + 25
CS KTU Lectures
Find the Ω notation of the following function
f(n) = 3n + 6n2 + 3n
CS KTU Lectures
Find the Ω notation of the following function
f(n) = 3n + 6n2 + 3n
CS KTU Lectures
Find the Ω notation of the following function
f(n) = 3n + 6n2 + 3n
CS KTU Lectures
Find the Ω notation of the following function
3n + 6n2 + 3n ≥ 1 x 3n
CS KTU Lectures
Find the Ω notation of the following function
3n + 6n2 + 3n ≥ 1 x 3n
CS KTU Lectures
Find the Ω notation of the following function
3n + 6n2 + 3n ≥ 1 x 3n
CS KTU Lectures
Find the Ω notation of the following function
3n + 6n2 + 3n ≥ 1 x 3n
CS KTU Lectures
Find the Ω notation of the following function
f(n) = 3n + 6n2 + 3n
CS KTU Lectures
Find the Ω notation of the following function
f(n) = 3n + 6n2 + 3n
CS KTU Lectures
Find the Ω notation of the following function
f(n) = 3n + 6n2 + 3n
3n + 6n2 + 3n = Ω(3n)
CS KTU Lectures
Theta (Ɵ) Notation
Definition:
The function f(n) = Ɵ (g(n)) iff there exists 3
positive constants c1, c2 and n0 such that
0 ≤ c1 g(n) ≤ f(n) ≤ c2 g(n) for all n ≥ n0
CS KTU Lectures
Theta (Ɵ) Notation
• It is the measure of average amount of time
taken by an algorithm(Average case)
CS KTU Lectures
Find the Ɵ notation of the following function
f(n) = 3n + 2
CS KTU Lectures
Find the Ɵ notation of the following function
f(n) = 3n + 2
0 ≤ c1 g(n) ≤ f(n) ≤ c2 g(n) for all n ≥ n0
CS KTU Lectures
Find the Ɵ notation of the following function
f(n) = 3n + 2
0 ≤ c1 g(n) ≤ f(n) ≤ c2 g(n) for all n ≥ n0
CS KTU Lectures
Find the Ɵ notation of the following function
f(n) = 3n + 2
0 ≤ c1 g(n) ≤ f(n) ≤ c2 g(n) for all n ≥ n0
CS KTU Lectures
Find the Ɵ notation of the following function
f(n) = 3n + 2
0 ≤ c1 g(n) ≤ f(n) ≤ c2 g(n) for all n ≥ n0
CS KTU Lectures
Find the Ɵ notation of the following function
f(n) = 3n + 2
0 ≤ c1 g(n) ≤ f(n) ≤ c2 g(n) for all n ≥ n0
CS KTU Lectures
Find the Ɵ notation of the following function
f(n) = 3n + 2
0 ≤ c1 g(n) ≤ f(n) ≤ c2 g(n) for all n ≥ n0
3 n ≤ 3n + 2 ≤ 4 n for all n ≥ 2 c1 =3 c2 =4 n0 =2
CS KTU Lectures
Find the Ɵ notation of the following function
f(n) = 3n + 2
0 ≤ c1 g(n) ≤ f(n) ≤ c2 g(n) for all n ≥ n0
3 n ≤ 3n + 2 ≤ 4 n for all n ≥ 2 c1 =3 c2 =4 n0 =2
CS KTU Lectures
Find the Ɵ notation of the following function
f(n) = 3 x 2n + 4n2 + 5n + 2
CS KTU Lectures
Find the Ɵ notation of the following function
f(n) = 3 x 2n + 4n2 + 5n + 2
0 ≤ c1 g(n) ≤ f(n) ≤ c2 g(n) for all n ≥ n0
CS KTU Lectures
Find the Ɵ notation of the following function
f(n) = 3 x 2n + 4n2 + 5n + 2
0 ≤ c1 g(n) ≤ f(n) ≤ c2 g(n) for all n ≥ n0
CS KTU Lectures
Find the Ɵ notation of the following function
f(n) = 3 x 2n + 4n2 + 5n + 2
0 ≤ c1 g(n) ≤ f(n) ≤ c2 g(n) for all n ≥ n0
CS KTU Lectures
Find the Ɵ notation of the following function
f(n) = 3 x 2n + 4n2 + 5n + 2
0 ≤ c1 g(n) ≤ f(n) ≤ c2 g(n) for all n ≥ n0
CS KTU Lectures
Find the Ɵ notation of the following function
f(n) = 3 x 2n + 4n2 + 5n + 2
0 ≤ c1 g(n) ≤ f(n) ≤ c2 g(n) for all n ≥ n0
CS KTU Lectures
Find the Ɵ notation of the following function
f(n) = 3 x 2n + 4n2 + 5n + 2
0 ≤ c1 g(n) ≤ f(n) ≤ c2 g(n) for all n ≥ n0
CS KTU Lectures
Find the Ɵ notation of the following function
f(n) = 3 x 2n + 4n2 + 5n + 2
0 ≤ c1 g(n) ≤ f(n) ≤ c2 g(n) for all n ≥ n0
Therefore Lectures
f(n) = Ɵ(g(n))CS KTU 3 x 2n + 4n2 + 5n + 2 = Ɵ(2n )
Little oh (o) Notation
Definition:
The function f(n) = o(g(n)) iff for any positive
constant c>0, there exists a constant n0>0 such
that 0 ≤ f(n) < c g(n) for all n ≥ n0