Lesson 11 · Python
Algorithms: Complexity & Big-O
Reason about code cost the way professionals do: count operations with big-O notation, tell best from worst case, and measure honestly with timeit.
Prerequisites: Object-Oriented Capstone — Design a Real Program
Learning objectives
By the end of this lesson, you will be able to:
- Count an algorithm's operations instead of timing it in seconds
- Classify code shapes as O(1), O(log n), O(n), O(n log n), O(n²) or O(2ⁿ)
- Distinguish best, average and worst cases for the same algorithm
- Include space complexity when comparing two solutions
- Measure code honestly with timeit and explain why one-off wall-clock timings mislead