Comments

Notes

MCS 211

18 topics

Asymptotic Analysis and Notations

Updated Jan 21, 20253 min read

Asymptotic Analysis is a mathematical method used to describe the efficiency of an algorithm as its input size (nnn) grows large. It provides a way to compare algorithms by focusing on their growth rates rather than exact execution times or specific hardware configurations.​

Need of Asymptotic Analysis

  • time complexityspace complexityTo estimate (execution time) and (memory usage).
  • To focus on the dominant factors affecting performance for large inputs.
  • To provide a platform-independent way to compare algorithms.

Asymptotic Notations

Asymptotic notations are mathematical tools used to describe the upper, lower, and tight bounds of an algorithm's performance.

Big-O Notation (OOO)

  • Definition:  Describes the Upper Bound  of an algorithm's running time. It represents the worst-case scenario.
    Big O is used to represent the upper bound or a worst case of an algorithm since it bounds the growth of the running timefrom above for large value of input sizes. It notifies that a particular procedure willnever go beyond a specific time for every input n.notation is that it makes algorithms much easier to analyze, since we can convenientlyignore low-order terms.
  • Expression: T(n)∈O(g(n))if there exist constants c>0 and n0​ such that T(n)≤c⋅g(n) for all n≥n0​.
  • Example:
    If T(n)=3n2+5n+7T(n) = 3n^2 + 5n + 7T(n)=3n2+5n+7, then T(n)∈O(n2)T(n) \in O(n^2)T(n)∈O(n2).
Big O Notation

Omega Notation (Ω\OmegaΩ)

​Definition: Describes the lower bound of an algorithm's running time. It represents the best-case scenario.

Expression:

T(n)∈Ω(g(n))T(n)∈Ω(g(n))T(n)∈Ω(g(n)) if there exist constants c > 0 and n0 such that T(n)≥c⋅g(n) for all n ≥ n0.

Example:

If T(n)=3n2+5n+7T(n) = 3n^2 + 5n + 7T(n)=3n2+5n+7T(n)=3n^2+5n+7T(n)=3n2+5n+7​, then T(n)∈Ω(n2)T(n)∈Ω(n ^2)T(n)∈Ω(n2). 

Big Omega Notation

Theta Notation (Θ\ThetaΘ)​

​Definition: Describes the tight bound of an algorithm's running time. It represents both the best-case and worst-case scenarios.​

Expression:

T(n)∈Θ(g(n))if there exist constants c1,c2>0 and n0 such that c1⋅g(n)≤T(n)≤c2⋅g(n) for all n≥n0.

Example:

If T(n)=3n2+5n+7T(n) = 3n^2 + 5n + 7T(n)=3n2+5n+7T(n)=3n^2+5n+7T(n)=3n2+5n+7​, thenT(n)∈θ(n2)T(n)∈\theta(n ^2)T(n)∈θ(n2).  

Big Theta Notation

Common Time Complexities

Complexity
Notation
Example
Constant Time
O(1)
Accessing an element in an array
Logarithmic Time
O(logn)O(log_{n})O(logn​)​​
Binary search
Linear Time
O(n)
Linear search
Linearithmic Time
O(nlogn)O(nlogn)O(nlogn)​​
Merge sort, quicksort (average case)
Quadratic Time
O(n2)O(n ^ 2)O(n2)​​
Bubble sort, selection sort
Cubic Time
O(n3)O(n ^ 3)O(n3)​​
Matrix multiplication (naive approach)
Exponential Time
O(2n)O(2 ^ n )O(2n)​​
Solving the Tower of Hanoi, recursive DFS
Factorial Time
O(n!)
Solving the Traveling Salesman Problem



​


Key Points

  1. Why Use Asymptotic Analysis?

    • It abstracts away hardware details and focuses on growth trends.
    • It helps predict performance for large-scale inputs.
  2. Importance of Worst-Case Analysis (Big-O):

    • Ensures performance does not degrade unexpectedly.
    • Provides a reliable upper bound.
  3. Compare Algorithms:

    • For small input sizes, actual performance may differ, but for large inputs, asymptotic trends dominate.

​

Share