CoursifyCoursify

Asymptotic Analysis

Asymptotic Analysis

Verified Sources
May 25, 2026

Asymptotic analysis is the mathematical framework used to compare algorithms by how their running time or space complexity grows with input size nn, especially for large nn.2 Instead of focusing on exact machine-dependent timings, it emphasizes long-run growth rate and abstracts away constant factors and lower-order terms when they do not affect scalability.2

This perspective is essential because two algorithms may behave differently for small inputs yet reveal a consistent ordering for sufficiently large nn. For example, an algorithm with runtime 100n100n can outperform one with runtime n2n^2 for small nn, but the quadratic algorithm eventually grows faster and becomes less efficient as nn increases.

The main notational tools are Big-O for upper bounds, Big-Omega for lower bounds, and Big-Theta for tight bounds.2 These notations are used in algorithm analysis, proof of lower bounds, recurrence solving, and classification of computational efficiency.2

Footnotes

  1. Asymptotic Notation: O(), o(), Ω(), ω(), and Θ() The Idea The Definitions - University of Arizona notes defining the standard asymptotic notations formally. 2

  2. Recurrences, Master Theorem - University of Washington lecture notes connecting asymptotic analysis with case analysis and recursive algorithms. 2

  3. What is Big O Notation Explained: Space and Time Complexity - Accessible summary of Big-O, Omega, Theta, and little-o definitions. 2

  4. Lecture 16: Introduction to Asymptotic Analysis - Cornell lecture explaining simplification, growth comparison, and why asymptotic thinking focuses on large inputs. 2 3

  5. Asymptotic Analysis and Recurrences - CMU lecture covering asymptotic notation, lower bounds, and recurrence-solving methods.

Asymptotic Notations 101: Big O, Big Omega, & Theta

Why asymptotic analysis matters

Exact runtime in seconds depends on hardware, compiler, language, and implementation details. Asymptotic analysis isolates the growth trend that remains meaningful across environments.2

Footnotes

  1. Recurrences, Master Theorem - University of Washington lecture notes connecting asymptotic analysis with case analysis and recursive algorithms.

  2. Lecture 16: Introduction to Asymptotic Analysis - Cornell lecture explaining simplification, growth comparison, and why asymptotic thinking focuses on large inputs.

Formal asymptotic notations

Let f(n)f(n) and g(n)g(n) be positive functions. Then the standard definitions are:2

  • f(n)O(g(n))f(n) \in O(g(n)) if there exist constants c>0c>0 and n0n_0 such that

    0f(n)cg(n)for all nn00 \le f(n) \le c\,g(n)\quad \text{for all } n \ge n_0

    So g(n)g(n) is an asymptotic upper bound.

  • f(n)Ω(g(n))f(n) \in \Omega(g(n)) if there exist constants c>0c>0 and n0n_0 such that

    0cg(n)f(n)for all nn00 \le c\,g(n) \le f(n)\quad \text{for all } n \ge n_0

    So g(n)g(n) is an asymptotic lower bound.2

  • f(n)Θ(g(n))f(n) \in \Theta(g(n)) if there exist constants c1,c2>0c_1,c_2>0 and n0n_0 such that

    0c1g(n)f(n)c2g(n)for all nn00 \le c_1 g(n) \le f(n) \le c_2 g(n)\quad \text{for all } n \ge n_0

    This means g(n)g(n) is a tight bound from both above and below.2

A useful interpretation is:

  • O(g(n))O(g(n)): “at most this fast”
  • Ω(g(n))\Omega(g(n)): “at least this fast”
  • Θ(g(n))\Theta(g(n)): “grows at this rate asymptotically”2

Two additional notations appear in more mathematical treatments:

  • little-o: f(n)f(n) grows strictly slower than g(n)g(n)
  • little-omega: f(n)f(n) grows strictly faster than g(n)g(n)

For example, 7n+8Θ(n)7n+8 \in \Theta(n) because constants and additive terms do not change the long-run linear growth class.2

Footnotes

  1. Asymptotic Notation: O(), o(), Ω(), ω(), and Θ() The Idea The Definitions - University of Arizona notes defining the standard asymptotic notations formally. 2 3 4 5 6

  2. What is Big O Notation Explained: Space and Time Complexity - Accessible summary of Big-O, Omega, Theta, and little-o definitions. 2

  3. Asymptotic Analysis and Recurrences - CMU lecture covering asymptotic notation, lower bounds, and recurrence-solving methods. 2

  4. Recurrences, Master Theorem - University of Washington lecture notes connecting asymptotic analysis with case analysis and recursive algorithms.

  5. Lecture 16: Introduction to Asymptotic Analysis - Cornell lecture explaining simplification, growth comparison, and why asymptotic thinking focuses on large inputs.

If an algorithm takes no more than some constant multiple of g(n)g(n) for sufficiently large nn, then its runtime is O(g(n))O(g(n)).

Footnotes

  1. Asymptotic Notation: O(), o(), Ω(), ω(), and Θ() The Idea The Definitions - University of Arizona notes defining the standard asymptotic notations formally.

Common growth classes and their significance

In algorithm design, the most common asymptotic classes are constant, logarithmic, linear, linearithmic, polynomial, and exponential.2 Their order from slower to faster growth is typically:

1  <  logn  <  n  <  nlogn  <  n2  <  n3  <  2n1 \;<\; \log n \;<\; n \;<\; n\log n \;<\; n^2 \;<\; n^3 \;<\; 2^n

This ranking is why binary search with Θ(logn)\Theta(\log n) is asymptotically better than linear search with Θ(n)\Theta(n) on sorted data, and why efficient comparison sorts aim for Θ(nlogn)\Theta(n\log n) rather than Θ(n2)\Theta(n^2).2

Growth classTypical notationExample algorithmic patternPractical meaning
ConstantΘ(1)\Theta(1)Array indexingCost does not grow with nn
LogarithmicΘ(logn)\Theta(\log n)Binary searchInput shrinks by a constant factor each step2
LinearΘ(n)\Theta(n)Single pass through dataCost scales proportionally with input size
LinearithmicΘ(nlogn)\Theta(n\log n)Merge sortNear-optimal for many sorting problems2
QuadraticΘ(n2)\Theta(n^2)Double nested loopsOften too slow for large inputs2
PolynomialΘ(nk)\Theta(n^k)Dense dynamic programsGrowth depends on fixed exponent kk
ExponentialΘ(2n)\Theta(2^n)Exhaustive subset searchBecomes infeasible quickly

Footnotes

  1. Lecture 16: Introduction to Asymptotic Analysis - Cornell lecture explaining simplification, growth comparison, and why asymptotic thinking focuses on large inputs. 2

  2. Learn Asymptotic Notation in Y Minutes - Concise overview of common growth classes and notation relationships. 2 3 4 5 6 7 8 9

  3. Asymptotic Analysis and Recurrences - CMU lecture covering asymptotic notation, lower bounds, and recurrence-solving methods. 2 3

Relative growth classes in asymptotic analysis

Illustrative ranking of common complexity classes from slower to faster asymptotic growth.2

Footnotes

  1. Lecture 16: Introduction to Asymptotic Analysis - Cornell lecture explaining simplification, growth comparison, and why asymptotic thinking focuses on large inputs.

  2. Learn Asymptotic Notation in Y Minutes - Concise overview of common growth classes and notation relationships.

Big-O is not always an exact description

Big-O gives an upper bound, which may be tight or loose. Saying an algorithm is O(n2)O(n^2) can be true even if its tighter bound is actually Θ(n)\Theta(n).2

Footnotes

  1. Asymptotic Notation: O(), o(), Ω(), ω(), and Θ() The Idea The Definitions - University of Arizona notes defining the standard asymptotic notations formally.

  2. Asymptotic Analysis and Recurrences - CMU lecture covering asymptotic notation, lower bounds, and recurrence-solving methods.

Simplification rules used in asymptotic analysis

A central technique is asymptotic simplification: remove terms that become negligible as nn \to \infty.2 This follows from comparing dominant growth.

Examples:2

  • 3n2+5n+7Θ(n2)3n^2 + 5n + 7 \in \Theta(n^2)
  • nlogn+100nΘ(nlogn)n\log n + 100n \in \Theta(n\log n)
  • 4Θ(1)4 \in \Theta(1)
  • log2nΘ(logn)\log_2 n \in \Theta(\log n) because changing the logarithm base changes only a constant factor.

Useful rules:

  1. Drop constants: cf(n)Θ(f(n))c\cdot f(n) \in \Theta(f(n)) for constant c>0c>0.
  2. Keep the dominant term: if f(n)=g(n)+h(n)f(n)=g(n)+h(n) and g(n)g(n) grows faster, then f(n)Θ(g(n))f(n)\in\Theta(g(n)).
  3. Multiply nested costs: an outer loop of nn iterations and inner loop of nn iterations yields Θ(n2)\Theta(n^2) if both run fully.
  4. Sequential composition adds: if one part costs Θ(n)\Theta(n) and another Θ(n2)\Theta(n^2), total cost is Θ(n2)\Theta(n^2).

These rules are valid only in the asymptotic sense; for small inputs, constants may still affect real performance.

Footnotes

  1. Lecture 16: Introduction to Asymptotic Analysis - Cornell lecture explaining simplification, growth comparison, and why asymptotic thinking focuses on large inputs. 2 3 4 5 6 7

  2. Learn Asymptotic Notation in Y Minutes - Concise overview of common growth classes and notation relationships. 2

  3. Asymptotic Notation: O(), o(), Ω(), ω(), and Θ() The Idea The Definitions - University of Arizona notes defining the standard asymptotic notations formally.

How to analyze an algorithm asymptotically

  1. 1
    Step 1

    Choose the variable that meaningfully measures problem size, usually nn. For graphs, it may be vertices VV and edges EE rather than a single variable.

    Footnotes

    1. Recurrences, Master Theorem - University of Washington lecture notes connecting asymptotic analysis with case analysis and recursive algorithms.

  2. 2
    Step 2

    Count primitive operations, comparisons, assignments, recursive calls, or memory cells under a consistent abstraction.2

    Footnotes

    1. Recurrences, Master Theorem - University of Washington lecture notes connecting asymptotic analysis with case analysis and recursive algorithms.

    2. Asymptotic Analysis and Recurrences - CMU lecture covering asymptotic notation, lower bounds, and recurrence-solving methods.

  3. 3
    Step 3

    Express runtime or space as a function such as T(n)T(n) by analyzing loops, branches, and recursion.2

    Footnotes

    1. Recurrences, Master Theorem - University of Washington lecture notes connecting asymptotic analysis with case analysis and recursive algorithms.

    2. Asymptotic Analysis and Recurrences - CMU lecture covering asymptotic notation, lower bounds, and recurrence-solving methods.

  4. 4
    Step 4

    If runtime depends strongly on input arrangement, derive separate best-case, average-case, and worst-case functions.

    Footnotes

    1. Recurrences, Master Theorem - University of Washington lecture notes connecting asymptotic analysis with case analysis and recursive algorithms.

  5. 5
    Step 5

    Discard constants and lower-order terms that do not affect growth for sufficiently large nn.2

    Footnotes

    1. Lecture 16: Introduction to Asymptotic Analysis - Cornell lecture explaining simplification, growth comparison, and why asymptotic thinking focuses on large inputs.

    2. Learn Asymptotic Notation in Y Minutes - Concise overview of common growth classes and notation relationships.

  6. 6
    Step 6

    Use OO, Ω\Omega, or Θ\Theta according to whether you established an upper bound, lower bound, or tight bound.2

    Footnotes

    1. Asymptotic Notation: O(), o(), Ω(), ω(), and Θ() The Idea The Definitions - University of Arizona notes defining the standard asymptotic notations formally.

    2. What is Big O Notation Explained: Space and Time Complexity - Accessible summary of Big-O, Omega, Theta, and little-o definitions.

Best-case, average-case, and worst-case analysis

Case analysis matters when the same algorithm behaves differently on different inputs of the same size. For example, linear search may terminate immediately if the target is first, or inspect every element if the target is last or absent.

For a simple linear search over an array of size nn:

  • Best case: Θ(1)\Theta(1)
  • Worst case: Θ(n)\Theta(n)
  • Average case: typically Θ(n)\Theta(n) under common assumptions about target position

This shows an important distinction:

  • Asymptotic notation describes a growth relationship.
  • Best/worst/average describes which input distribution or scenario is being measured.

Thus, “worst-case Θ(n)\Theta(n)” and “best-case Θ(1)\Theta(1)” are both valid statements about the same algorithm.

Footnotes

  1. Recurrences, Master Theorem - University of Washington lecture notes connecting asymptotic analysis with case analysis and recursive algorithms. 2 3 4 5 6

Common misconceptions

Recurrences and divide-and-conquer analysis

Many recursive algorithms are modeled by a recurrence relation of the form

T(n)=aT(n/b)+f(n)T(n)=aT(n/b)+f(n)

where aa is the number of subproblems, n/bn/b is the subproblem size, and f(n)f(n) is the non-recursive work per level.2

This form captures divide-and-conquer algorithms such as merge sort and binary search. Common tools for solving recurrences include:

  • unrolling or repeated substitution
  • recursion trees
  • guessing and induction
  • the Master Theorem2

For the classic recurrence

T(n)=aT(n/b)+f(n),T(n)=aT(n/b)+f(n),

the Master Theorem compares f(n)f(n) to nlogban^{\log_b a}:2

  1. If f(n)=O(nlogbaε)f(n)=O(n^{\log_b a-\varepsilon}) for some ε>0\varepsilon>0, then T(n)=Θ(nlogba)T(n)=\Theta(n^{\log_b a})
  2. If f(n)=Θ(nlogbalogkn)f(n)=\Theta(n^{\log_b a}\log^k n) for some k0k\ge 0, then T(n)=Θ(nlogbalogk+1n)T(n)=\Theta(n^{\log_b a}\log^{k+1} n)
  3. If f(n)=Ω(nlogba+ε)f(n)=\Omega(n^{\log_b a+\varepsilon}) for some ε>0\varepsilon>0 and a regularity condition holds, then T(n)=Θ(f(n))T(n)=\Theta(f(n))

Example: merge sort satisfies

T(n)=2T(n/2)+Θ(n)T(n)=2T(n/2)+\Theta(n)

Here a=2a=2, b=2b=2, so nlogba=nn^{\log_b a}=n. Since f(n)=Θ(n)f(n)=\Theta(n) matches that term, this is Case 2, giving

T(n)=Θ(nlogn)T(n)=\Theta(n\log n)

2

Footnotes

  1. Asymptotic Analysis and Recurrences - CMU lecture covering asymptotic notation, lower bounds, and recurrence-solving methods. 2 3 4 5

  2. Master Theorem: Practice Problems and Solutions - Reference summary of the Master Theorem cases and regularity condition. 2 3 4

Solving a recurrence with the Master Theorem

  1. 1
    Step 1

    Express the runtime as T(n)=aT(n/b)+f(n)T(n)=aT(n/b)+f(n), identifying the number of recursive calls, shrink factor, and non-recursive work.2

    Footnotes

    1. Asymptotic Analysis and Recurrences - CMU lecture covering asymptotic notation, lower bounds, and recurrence-solving methods.

    2. Master Theorem: Practice Problems and Solutions - Reference summary of the Master Theorem cases and regularity condition.

  2. 2
    Step 2

    Evaluate nlogban^{\log_b a}, which represents the work implied by the recursive branching structure.

    Footnotes

    1. Master Theorem: Practice Problems and Solutions - Reference summary of the Master Theorem cases and regularity condition.

  3. 3
    Step 3

    Determine whether f(n)f(n) is polynomially smaller, equal up to logarithmic factors, or polynomially larger than nlogban^{\log_b a}.

    Footnotes

    1. Master Theorem: Practice Problems and Solutions - Reference summary of the Master Theorem cases and regularity condition.

  4. 4
    Step 4

    Apply Case 1, 2, or 3 depending on the comparison result.

    Footnotes

    1. Master Theorem: Practice Problems and Solutions - Reference summary of the Master Theorem cases and regularity condition.

  5. 5
    Step 5

    Conclude with a Θ\Theta bound, such as Θ(nlogn)\Theta(n\log n) for merge sort.2

    Footnotes

    1. Asymptotic Analysis and Recurrences - CMU lecture covering asymptotic notation, lower bounds, and recurrence-solving methods.

    2. Master Theorem: Practice Problems and Solutions - Reference summary of the Master Theorem cases and regularity condition.

Worked examples

Consider several common algorithmic patterns:3

  1. Single loop

    1for i = 1 to n: 2 constant work

    Runtime: Θ(n)\Theta(n)

  2. Nested loops

    1for i = 1 to n: 2 for j = 1 to n: 3 constant work

    Runtime: Θ(n2)\Theta(n^2)

  3. Halving loop

    1while n > 1: 2 n = n/2

    Runtime: Θ(logn)\Theta(\log n) because the input shrinks by a factor of 2 each iteration.2

  4. Binary search Each recursive or iterative step halves the search interval, giving Θ(logn)\Theta(\log n) worst-case runtime on sorted arrays.2

  5. Linear search Runtime is Θ(1)\Theta(1) in the best case and Θ(n)\Theta(n) in the worst case.

A useful heuristic is to ask whether the algorithm:

  • processes every element once Θ(n)\rightarrow \Theta(n)
  • uses two independent passes over all pairs Θ(n2)\rightarrow \Theta(n^2)
  • repeatedly halves the problem Θ(logn)\rightarrow \Theta(\log n)
  • recursively splits into balanced subproblems plus linear merge work Θ(nlogn)\rightarrow \Theta(n\log n)2

Footnotes

  1. Recurrences, Master Theorem - University of Washington lecture notes connecting asymptotic analysis with case analysis and recursive algorithms. 2 3

  2. Lecture 16: Introduction to Asymptotic Analysis - Cornell lecture explaining simplification, growth comparison, and why asymptotic thinking focuses on large inputs. 2

  3. Asymptotic Analysis and Recurrences - CMU lecture covering asymptotic notation, lower bounds, and recurrence-solving methods. 2 3 4

  4. Learn Asymptotic Notation in Y Minutes - Concise overview of common growth classes and notation relationships.

Pro tip for loop analysis

When loops are nested, multiply iteration counts only if the inner loop runs fully for each outer iteration. If bounds depend on the outer index, the total may be triangular, such as i=1ni=Θ(n2)\sum_{i=1}^{n} i = \Theta(n^2) rather than exactly n2n^2.

Footnotes

  1. Lecture 16: Introduction to Asymptotic Analysis - Cornell lecture explaining simplification, growth comparison, and why asymptotic thinking focuses on large inputs.

Limits, ratios, and proving asymptotic relationships

A mathematically precise way to compare functions is with ratios and limits.2 If

limnf(n)g(n)=c\lim_{n\to\infty}\frac{f(n)}{g(n)} = c

for some constant cc with 0<c<0<c<\infty, then typically f(n)Θ(g(n))f(n)\in\Theta(g(n)).2

Examples:

  • limn7n+8n=7\displaystyle \lim_{n\to\infty}\frac{7n+8}{n}=7, so 7n+8Θ(n)7n+8\in\Theta(n).
  • limnnn2=0\displaystyle \lim_{n\to\infty}\frac{n}{n^2}=0, so no(n2)n\in o(n^2).
  • limnn2n=\displaystyle \lim_{n\to\infty}\frac{n^2}{n}= \infty, so n2ω(n)n^2\in \omega(n).

This ratio perspective explains why lower-order terms vanish asymptotically: their contribution becomes negligible relative to the dominant term.2

Footnotes

  1. Asymptotic Notation: O(), o(), Ω(), ω(), and Θ() The Idea The Definitions - University of Arizona notes defining the standard asymptotic notations formally. 2 3 4 5 6

  2. What is Big O Notation Explained: Space and Time Complexity - Accessible summary of Big-O, Omega, Theta, and little-o definitions. 2

  3. Lecture 16: Introduction to Asymptotic Analysis - Cornell lecture explaining simplification, growth comparison, and why asymptotic thinking focuses on large inputs.

Applications and edge cases

Summary framework

A rigorous mental model for algorithm analysis is:

  1. Model runtime or memory as a function T(n)T(n).
  2. If needed, separate best, average, and worst cases.
  3. Simplify to its dominant asymptotic growth class.
  4. Express the result with the appropriate notation: OO, Ω\Omega, or Θ\Theta.2
  5. For recursive algorithms, formulate and solve a recurrence, often with the Master Theorem.2

In this way, asymptotic analysis turns implementation behavior into a mathematical object that can be compared, proved, and generalized across machines and programming languages.2

Footnotes

  1. Recurrences, Master Theorem - University of Washington lecture notes connecting asymptotic analysis with case analysis and recursive algorithms. 2 3

  2. Lecture 16: Introduction to Asymptotic Analysis - Cornell lecture explaining simplification, growth comparison, and why asymptotic thinking focuses on large inputs.

  3. Asymptotic Notation: O(), o(), Ω(), ω(), and Θ() The Idea The Definitions - University of Arizona notes defining the standard asymptotic notations formally.

  4. What is Big O Notation Explained: Space and Time Complexity - Accessible summary of Big-O, Omega, Theta, and little-o definitions.

  5. Asymptotic Analysis and Recurrences - CMU lecture covering asymptotic notation, lower bounds, and recurrence-solving methods. 2

  6. Master Theorem: Practice Problems and Solutions - Reference summary of the Master Theorem cases and regularity condition.

Knowledge Check

Question 1 of 4
Q1Single choice

What does it mean to say that a runtime function T(n)T(n) is Θ(g(n))\Theta(g(n))?

Explore Related Topics

1

Complexity Analysis of a Divide-and-Conquer Recurrence

The course explains how to determine the asymptotic complexity of the divide‑and‑conquer recurrence T(n)=2T(n/4)+n2lognT(n)=2T(n/4)+n^{2}\log n.

  • Identify parameters: a=2a=2, b=4b=4, f(n)=n2lognf(n)=n^{2}\log n.
  • Critical exponent logba=log42=0.5\log_b a=\log_4 2=0.5, so leaf cost grows as n0.5n^{0.5}.
  • Since f(n)=Ω ⁣(n0.5+ϵ)f(n)=\Omega\!\big(n^{0.5+\epsilon}\big) for ϵ1.5\epsilon\le1.5, Case 3 of the Master Theorem applies.
  • Regularity condition holds with c=1/8<1c=1/8<1, confirming dominance of the root work.
  • Consequently T(n)=Θ(n2logn)T(n)=\Theta(n^{2}\log n), which is also derived via recursion‑tree and Akra‑Bazzi methods.
2

The Banker's Algorithm: Deadlock Avoidance in Operating Systems

The Banker's Algorithm is a deadlock‑avoidance method that keeps a system in a safe state by checking each resource request against the maximum declared needs of processes.

  • Maintains Available, Max, Allocation, and Need matrices, where Need[i][j]=Max[i][j]Allocation[i][j]\text{Need}[i][j]=\text{Max}[i][j]-\text{Allocation}[i][j].
  • The Safety Algorithm uses vectors Work and Finish to find an execution order; if all processes finish, the state is safe.
  • The Resource‑Request Algorithm simulates allocation, runs the safety check, and commits only if the resulting state remains safe.
  • Time complexity of the safety check is O(m×n2)O(m \times n^{2}).
  • In practice the algorithm is rarely used because processes must predeclare maximum needs and the algorithm’s overhead is high.
3

Asymptotic Notation in Algorithm Analysis

Chat with Kiro