Browse Curriculum

Big-O Notation

The language we use to describe the performance of algorithms.

Question 1/4

Score: 0
for (let i = 0; i < n; i++) {
    console.log(i);
}

Intuition

Imagine you're buying a car. You don't ask "exactly how many milliseconds does it take to go 0-60?". You ask "is it a sports car, a sedan, or a truck?". Big-O is that classification system for algorithms.

Concept

  • Upper Bound: Big-O describes the ceiling of growth. It won't get worse than this.
  • Asymptotic Analysis: We only care about large inputs (N → ∞).
  • Drop Constants: O(2n) is just O(n). O(n² + n) is just O(n²).

How it Works

The Rules:

  • Loops: Multiply complexity by N.
  • Nested Loops: Multiply inner by outer (N * N = N²).
  • Halving: If loop variable is divided/multiplied, it's Logarithmic.

Step-by-Step Breakdown

Play the Quiz Game to practice identifying complexities!

When to Use

  • When designing any system to ensure scalability.
  • In technical interviews!

When NOT to Use

  • When N is guaranteed to be very small (e.g., sorting 5 items).

How to Identify

"Analyze the complexity", "Will this scale?", "Optimize".

Sample Problems

Frequently Asked Questions

What is Big-O Notation?

The language we use to describe the performance of algorithms.


What is the time complexity of Big-O Notation?

The time complexity is: Best case N/A, Average case N/A, Worst case N/A. Space complexity is varies.