Browsing as a guest — you can read this lesson freely, but you'll need to sign in to save notes or track progress.

Sign In
02

1 RuntimeAnalysis Lesson

Topic 2: Runtime Analysis

Understanding Time Complexity & Big-O Notation

Learn how to measure algorithm efficiency and make smart design choices

The Library vs. The Messy Pile

Real-World Scenario

Imagine you need to find a specific book. You have two options:

Option A: The Organized Library

Books are sorted alphabetically on shelves. You know exactly which aisle and shelf to check.

  • • Walk to correct section
  • • Check specific shelf
  • • Find book in seconds
  • • Time: Almost instant
FAST: Binary Search

Option B: The Messy Pile

Books are scattered randomly in a huge pile on the floor. No organization whatsoever.

  • • Pick up first book, check title
  • • Not it? Try next one
  • • Keep checking one by one
  • • Time: Could take hours
SLOW: Linear Search

The Key Insight

The number of steps you take depends on how the data is organized. With 10,000 books, the library approach might take 14 checks maximum, while the pile approach could take all 10,000 checks in the worst case. This difference is what Big-O notation measures.

Keep reading — this lesson marks itself done automatically.