wisconsin
Asymptotic Analysis

Asymptotic Analysis

Curated by Last modified: 3 min read

Asymptotic analysis is a method of describing the limiting behavior of a function as the argument approaches a particular value or infinity. In computer science, asymptotic analysis is used to describe the performance or complexity of an algorithm.

This is otherwise known as complexity analysis.

Notations

There are three common notations used in asymptotic analysis:

  1. Big O Notation ()
  2. Omega Notation ()
  3. Theta Notation ()

Big O Notation

Big O notation is used to describe the upper bound of an algorithm’s time complexity. It provides an upper limit on the growth rate of the algorithm.

Mathematically, is the set of functions that grow at most as fast as .

Tip

Big O notation is the most commonly used notation in complexity analysis, and can be though of as the worst-case scenario.

Omega Notation

Omega notation is used to describe the lower bound of an algorithm’s time complexity. It provides a lower limit on the growth rate of the algorithm.

Mathematically, is the set of functions that grow at least as fast as .

Tip

Omega notation is the best-case scenario.

Theta Notation

Theta notation is used to describe the tight bound of an algorithm’s time complexity. It provides both upper and lower limits on the growth rate of the algorithm.

Mathematically, is the set of functions that grow at the same rate as .

Tip

A bound existing implies and its converse, as and are the lower and upper bounds of .

Simplifying Notations

When analyzing the time complexity of an algorithm, we often simplify the notation to the dominant term. This is because the dominant term is the term that grows the fastest as the input size increases.

Therefore, when analyzing the time complexity of an algorithm, we often drop the lower-order terms and the coefficients of the dominant term.

Example

Consider the following function:

The dominant term in this function is . Therefore, the time complexity of this function is .

Example

Consider the following function:

The dominant term in this function is . Therefore, the time complexity of this function is . The base of the logarithm is not relevant in big O notation, as it is a constant factor, as proven by the change of base formula.

Common Notations

The following table summarizes the common notations used in asymptotic analysis:

NotationDescriptionExample
Constant timeAccessing an element in an array
Logarithmic timeBinary search
Linear timeLinear search
Linearithmic timeMerge sort
Quadratic timeBubble sort
Cubic timeMatrix multiplication
Exponential timeRecursive Fibonacci sequence
Factorial timePermutations of a set

Calculating Time Complexity

Oftentimes, it is useful to calculate the work done at each “level” of an algorithm. This can be done by summing the work done at each level and then simplifying the notation to the dominant term.

Example

Consider the following algorithm:

int sum = 0;
for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
        sum++;
    }
}

The work done at each level is as follows:

  • Level 1: operations
  • Level 2: operations

Therefore, the total work done by the algorithm is .

Tip

In mathematics, there are a few summation formulas that are useful for calculating the work done at each level of an algorithm:

If the work follows a sequence of , the sum is , which simplifies to .

If the work follows a sequence of , the sum is , which simplifies to .

Source

The existing course note was retained and normalized during the merge.

Related: Topic index.

Linked to this page