Skip to content
Guest
Learn DSA · Course Syllabus Show lessons
Complexity & Patterns · 8 min read · Intermediate

Big-O Complexity & Growth Rates

Compare O(1), O(log n), O(n), O(n log n), and O(n^2) to spot performance bottlenecks before they hit production.

What you'll learn

  • Rank common Big-O time complexities from fastest to slowest
  • Understand why constants and lower-order terms are dropped in Big-O
  • Analyze both time complexity and auxiliary space complexity

Big-O notation measures how an algorithm’s runtime or memory grows as input size n increases:

  • O(1): Array index lookup, Hash Map get/set.
  • O(log n): Binary search (halves the search space each step).
  • O(n): Single pass over an array.
  • O(n log n): Efficient sorting (Merge Sort, Timsort).
  • O(n^2): Nested loops comparing every pair of items (slow at n = 100,000).

Fill-in-the-Blank Exercise

Identify Complexity

A single pass loop is O(n), while checking all pairs with a nested loop is O(n^2).

// Single pass: O()
// Nested pair check: O()
// Binary search: O(log n)

Live DSA Playground

Compare O(n) vs O(n^2) Step Counts
Live Result
Console Output

No console output yet. Try calling console.log(...) in JS.

Check Your Understanding

Score: 0 / 1

1. What is the Big-O time complexity of two separate sequential for-loops each running n times?

Study Workspace

Finished this lesson?

Your progress is saved locally in your browser, no account needed.

Search courses, lessons, and references

Type to search across all courses, lessons, and quick references.

Press Esc to close Powered by Pagefind