UNIT I - Session 4
UNIT I - Session 4
INTRODUCTION TO ALGORITM
DESIGN
Asymptotic Notations
Main idea of asymptotic analysis
◦ To have a measure of efficiency of algorithms
◦ That doesn’t depend on machine specific
constants,
◦ That doesn’t require algorithms to be
implemented
◦ Time taken by programs to be compared.
Asymptotic notations
◦ Asymptotic notations are mathematical tools to
represent time complexity of algorithms for
asymptotic analysis.
Asymptotic Analysis
Asymptotic analysis refers to computing
the running time of any operation in
mathematical units of computation.
◦ Ο Notation
◦ Ω Notation
◦ θ Notation
Big Oh Notation, Ο
◦ It measures the worst case time complexity or
longest amount of time an algorithm can
possibly take to complete.
O(g(n)) = { f(n): there exist positive constants c and n0 such that
0 <= f(n) <= cg(n) for all n >= n0}
0 <= f(n) <= cg(n) for all n >= n0}
log(logn)
Θ Notation:
Θ((g(n)) = {f(n): there exist positive constants c1, c2 and n0 such that
0 <= c1*g(n) <= f(n) <= c2*g(n) for all n >= n0}
0 <= c1*g(n) <= f(n) <= c2*g(n) for all n >= n0}
If f(n) = 3n+2
g(n)=n
Then
c1*g(n) <= f(n) <= c2*g(n)
C1,c2>0 and N>n0
For instance c2=4
f(n)<= c2g(n)
3n+2 <= 4n n0=1
f(n)>= c1g(n)
For instance c1=1
3n+2 >= n
Hence f(n) = theta(n)
Order of Growth Function