LESSON 02 / 75·2 min readFoundation

Big O notation

Must knowConcept lesson
01 Understand02 Recall03 Prepare

Overview

Big O tells you how the runtime or memory grows as input size increases.

Important ones

  • O(1): constant
  • O(log n): binary search, balanced BST operations
  • O(n): linear scan
  • O(n log n): merge sort, heap sort, efficient sorting
  • O(n^2): nested loops
  • O(2^n): recursion with repeated subproblems
  • O(n!): very expensive, usually not expected in interviews

Interview guidance

Usually, the best answer is the one with the lowest practical complexity under constraints.

Problems to practice

  • What is the time complexity of nested loops?
  • Why is hash map lookup O(1) average time?
  • Why is DFS O(V + E) for adjacency list graphs?

PAUSE & RECALL

Can you explain it without the notes?

Big O notation

Use your own words. Explain an example and one limitation before checking the explanation.

Check your explanation

What it is

CONNECT IT TO YOUR INTERVIEW

Turn this concept into a clear answer.

Practice this concept
YOUR NEXT STEP

Keep connecting the ideas.

Next lesson: Arrays and strings

Adapted from 14_DSA_MASTER.md · “2. Big O notation”. Examples are study fragments; framework behavior can depend on your version.