Module 2 · 3 lessons · about 3 hours 35 minutes
Counting steps: Big O
Counting the steps a loop takes, growth rates and Big O notation, reading constraints to know what speed you need, and the hidden loops inside everyday Python operations.
- Lessons
- 0/3
- Exercises
- 0/25
- Code
- 0/3
- Checkpoint
- Not taken
Already comfortable with this? Take the checkpoint cold. If you pass, move on and come back only for what you missed.
- 1Counting stepsBefore you can say what a solution costs, you count how many times its loop body runs. One loop over n items runs n times, two nested loops over the same items run n × n times, and a loop that halves what is left runs only 29 times on a billion items.1 h 5 min
- 2Growth rates and Big OBig O says how fast the work grows when the input grows. Keep the biggest term, drop the constants, and read a problem's size limit to know how fast your solution has to be before you write it.1 h 15 min
- 3What Python operations costSome single lines of Python are whole loops in disguise. Learn the price of everyday list, string, set and dict operations, why append is cheap on average, and how to price a function line by line.1 h 15 min
- Checkpoint11 questions. Pass with 80% to finish the module.