Analysis of Algorithms

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Analysis of Algorithms

Algorithm Analysis
Algorithm Analysis
Algorithm Analysis
Performance analysis

• Performance analysis of an algorithm is the


process of calculating space required by that
algorithm and time required by that
algorithm.
– Space required to complete the task of that
algorithm (Space Complexity). It includes program
space and data space
– Time required to complete the task of that
algorithm (Time Complexity)
Worst, Best and Average case
Worst, Best and Average case
Asymptotic Notation
• Asymptotic notation of an algorithm is a
mathematical representation of its complexity
• We use only the most significant terms in the
complexity of that algorithm and ignore least
significant terms in the complexity of that
algorithm
• we use THREE types of Asymptotic Notations
– Big - Oh (O)
– Big - Omega (Ω)
– Big - Theta (Θ)
Big - Oh Notation (O)
O(g(n)=pronounced “big-oh of g of n”)
– used to define the upper bound of an algorithm in terms of Time
complexity.

Big - Omega Notation (Ω)


Ω(g(n)=pronounced “big-omega of g of n”)
– used to define the lower bound of an algorithm in terms of Time
Complexity

Big - Theta Notation (Θ)


Θ(g(n)=pronounced “big-theta of g of n”)
– used to define the average bound of an algorithm in terms of
Time Complexity.
Running Time T(n)
Common Time Complexities

Better
O(1) constant time
O(log n) log time
O(n) linear time
O(n log n) log linear time
O(n2) quadratic time
O(n3) cubic time
Worse O(2n) exponential time

You might also like