Time & Space Complexity
Predict whether a solution will finish in time before you write it, by counting how the work grows as the input grows.
After this lesson you will be able to
- Explain why we measure growth in the number of steps rather than seconds on a stopwatch.
- Read Big-O notation and drop constants and lower-order terms correctly.
- Identify O(1), O(log n), O(n), O(n log n), O(n²) and O(2ⁿ) from the shape of the code.
- Use the input limits in a problem statement to decide which complexities can pass.
- Describe space complexity and the call-stack cost of recursion.
Before you start. You should be able to read a for loop and a while loop in Python.