Session3 - Asymptotic Notations
Session3 - Asymptotic Notations
Unit-1
Introduction to Algorithms
Session-3
Asymptotic Notations
9
Little ο asymptotic notation
Big-Ο is used as a tight upper-bound on the growth of an algorithm’s effort.
Example 1: f(n)=3n2+2n+1
Example1. : f(n)=3n+2
1) We show that f(n)<=C1.g(n)
• let g(n)=n and C1=4
• by def. of Big-O
• 3n+2<=4 n which is true for all n>2(n0)
2) Now we have to show C2.g(n)<=f(n) for satisfying omega notation
• here g(n)=n, let C2=1, then
• 1. n<=3n+2 is also true for all n>2(n0)
• Therefore by definition of theta notation
• F(n)= Θ(g(n))= Θ(n) for constants C1=4 and C2=1 for all n>2
Theta Notation(θ)
Q-4) Suppose you have algorithms with the five running times listed
below. How much slower do each of these algorithms get when you (a)
double the input size, or (b) increase the input size by one?
1. n2 ;
2. n3 ;
3. 100n2 ;
4. nlog(n);
5. 2n
Test Your Knowledge
Q 3. If f(n) = n+2, Can we write f(n)=O(n2) ?