Skip to content

Asymptotic Notations

Course: Arrays - chapter 3

Asymptotic notations are the mathematical notations used to describe the running time of an algorithm when the input tends towards a particular value or a limiting value.

There are mainly three asymptotic notations:

  • Big-O notation
  • Omega notation
  • Theta notation

Big-O notation represents the upper bound of the running time of an algorithm. Thus, it gives the worst-case complexity of an algorithm.

We say, a function f(n) is O(g(n)) if there exists c and ⁍ > 0 such that

$$f(n) <= c*g(n) \space \forall \space n>=n_0$$

Examples:

f(n) = n^2 + 5n - 6

g(n) = 2n ^ 2

So g(n) ≥ f(n) ⁍ n ≥ 3 (Solved using quadratic equation)

So there exists, c = 2 and ⁍ = 3 such that f(n) ≤ c * g(n) for all n ≥ ⁍

So f(n) = O(g(n))

Omega notation represents the lower bound of the running time of an algorithm. Thus, it provides the best case complexity of an algorithm.

Ω(g(n)) = { f(n): there exist positive constants c and n0
such that 0 ≤ cg(n) ≤ f(n) for all n ≥ n0 }

For example, f(n) = n^2 and g(n) = n + 10

Theta notation encloses the function from above and below. Since it represents the upper and the lower bound of the running time of an algorithm, it is used for analyzing the average-case complexity of an algorithm.

Θ(g(n)) = { f(n): there exist positive constants c1, c2 and n0
such that 0 ≤ c1g(n) ≤ f(n) ≤ c2g(n) for all n ≥ n0 }