Lecture 02 Complexity Analysis
Lecture 02 Complexity Analysis
AND ALGORITHMS
g(n)=n2
g(n)=n2
If we have c=5 and n0=0 than clearly
5n2 <= f(n) , n >=0 so we can say Ω(n2)
Graph shows cg(n) will never exceed for all n>=n0
So, omega notation gives us lower bound of the rate of the growth of a function
ɵ-Theta Notation
ɵ(g(n)) = { f(n): there exist constant c1,c2 & n0,
c1*g(n)<= (f(n) <= c2*g(n) for n>=n0 }
Lets assume same example:
f(n)=5n2+2n+1
g(n)=n2
If we have c1=5,c2=8and n0=1 and our inequality will hold and we can say f(n) is ɵ (n2)
So, theta notation gives us tight bound of the rate of the growth of a function
Conclusion
In this Lecture we discussed…
What is an asymptotic analysis?
What are the Big-O, Omega and Theta notations?
ANY QUERY ?
Practice Questions
Question #8
Question #9
Question #10
Book “Data Structures and Algorithms in C++” Adam
Drozdek 4th Edition