Data Structures & Algorithms
Lesson 1 of 4 9 min +75 XP

Big-O Notation

Reason about how code scales.

What you'll learn

  • Read Big-O notation
  • Compare common complexities
  • Spot a linear scan
Finding a name in the phone book

Reading a phone book cover to cover to find one name is painfully slow, but flipping to the middle and halving each time is fast. Big-O notation is how we describe that difference — how much slower a method gets as the data grows huge.

Growth, not stopwatch time

Big-O describes how an algorithm's work grows with input size n, ignoring constants. O(1) is constant, O(n) grows linearly, O(n²) quadratically.

Hash map lookup

Looking up a key in a hash map is on average O(1) — independent of how many items it holds.

Knowledge Check

+20 XP / correct

1. Scanning every element of a list of size n once is…

2. Average-case lookup in a hash map is…