CS Pathfinder Logo CS Pathfinder

Unit 1 · Foundation of DSA

Asymptotic Notations

Learn Big O, Big Omega, and Big Theta notation with examples, comparison table, and beginner-friendly DSA explanations.

Introduction

Asymptotic notation is used to describe how an algorithm behaves when the input size becomes very large.

Instead of measuring exact time, we describe the growth pattern of an algorithm using notations like Big O, Big Omega, and Big Theta.

These notations make it easier to compare algorithms in a clean and machine-independent way.

Asymptotic Notations
        |
        +-- Big O: upper bound
        +-- Big Omega: lower bound
        +-- Big Theta: tight bound

Why We Use Asymptotic Notation

Machine Independent

It compares algorithms without depending on CPU speed.

Large Input Focus

It shows behavior when data becomes big.

Simple Comparison

It reduces complex formulas to growth classes.

DSA Standard

It is the common language for discussing efficiency.

Table of Contents

Big O Notation

Big O represents the upper bound of an algorithm. It describes the worst-case growth rate.

When we say linear search is O(n), we mean that in the worst case it may check all n elements.

Big O answers: How slow can this algorithm get as input grows?

Big Omega Notation

Big Omega represents the lower bound of an algorithm. It describes the best-case growth rate.

For linear search, the best case is finding the target at the first position, which is Omega(1).

Big Theta Notation

Big Theta represents a tight bound. It is used when upper and lower bounds grow at the same rate.

If an algorithm always checks every element exactly once, its time complexity can be Theta(n).

Growth Order

Some complexities grow much faster than others. This order is important while selecting algorithms.

  • O(1) is better than O(log n).
  • O(log n) is better than O(n).
  • O(n log n) is better than O(n^2).
  • O(2^n) and O(n!) become very slow for large input.

Big O, Big Omega, and Big Theta

Notation Meaning Common Use
Big O Upper bound Worst-case analysis
Big Omega Lower bound Best-case analysis
Big Theta Tight bound Exact growth class
Little o Strict upper bound Advanced comparison

C Program Example

This linear search example has best case Omega(1), worst case O(n), and average case O(n).

#include <stdio.h>

int main() {
    int arr[] = {5, 10, 15, 20};
    int key = 20;

    for (int i = 0; i < 4; i++) {
        if (arr[i] == key) {
            printf("Found");
            return 0;
        }
    }

    printf("Not found");
    return 0;
}

Output: Found

Key Points

  • Asymptotic notation describes algorithm growth for large input.
  • Big O is commonly used for worst-case upper bound.
  • Big Omega describes best-case lower bound.
  • Big Theta describes tight bound when growth is fixed.

Interview Tip

In most beginner DSA answers, interviewers expect Big O unless they specifically ask for Omega or Theta.

Common Beginner Mistakes

  • Using Big O as exact execution time.
  • Ignoring the difference between best, average, and worst case.
  • Keeping constants such as O(3n + 2) instead of simplifying to O(n).

Quick Revision

  • O = upper bound.
  • Omega = lower bound.
  • Theta = tight bound.
  • Growth rate matters more than exact operation count.

Summary

Asymptotic notations provide a standard way to describe algorithm efficiency. Big O, Big Omega, and Big Theta help compare solutions based on how their running time or memory usage grows.

Data Structures & Algorithms Handwritten Notes

Master DSA with 142 Pages of Easy Handwritten Notes – Perfect for Interviews, Placements, GATE & Exams.