Asymptotic Notations
Asymptotic notations are used to analyze algorithm’s run time performance. It represent the time complexity of the algorithm for asymptotic analysis. Best case, worst case and average case are very well examine with the asymptotic notations. Asymptotic notations are consider to be input bound scenario as no input is given to the algorithm then it is concluded to work in constant time. It compute the running time of any operation in mathematical unit of computation. For example, consider running time of one operation is f(n) and another operation is g(n2) means that the running time of first operation will increase linearly with the increase in n and the running time of second operation will increase exponentially when n increases. If n is small then the running time of both operation is same. Usually the time taken by algorithm falls under three types :
- Best case: Minimum time required for program execution.
- Average case: Average time required for program execution.
- Worst case: Maximum time required for program execution.
Following are the commonly used asymptotic notations :
- O notation
- Ω Notation
- θ Notation
Big Oh (O) Notation
The notation O(n) measures longest amount of time required for an algorithm to complete the execution or the worst case time complexity of an algorithm. It provides the upper bound of an algorithm’s running time.
For example for function f(n)
Ο (f(n)) = { g(n) : there exist a positive constant c and n0 as 0 ≤ f(n) ≤ c*g(n) for all n > n0}
Omega(Ω) Notation
Omega notation measures the best case time complexity of an algorithm or the best time taken to complete the execution. As the Big O notation gives an asymptotic upper bound on function, Omega (Ω) gives an asymptotic lower bound. Omega notation is rarely used notation among all three.
For example for function of f(n)
Ω (f (n)) ≥ { g(n) : there exist a positive constant c and n0 as g(n) ≤ c*f(n) for all n > n0 }
Theta (Θ) Notation
The asymptotic notation Θ(n) is used to express both lower bound as well as upper bound of the
algorithm’s running time.
For example for function of f(n)
Θ (f(n)) { g(n) if and only if g(n) = Ο (f(n)) and g(n) = Ω (f(n)) for all n > n0 }