AI Hints
Home›DSA in Python Tutorial›Space and Time
DSA in Python · Lesson 12 of 132

Big O Quiz

Test yourself.

⏱ 2 min read▶ Video at 12:37🎓 Free
Watch this lesson in the DSA in Python courseWatch on YouTube ↗Full DSA in Python course

Let's check that Big O has clicked. Pause on each question, decide your answer, and then listen for the explanation.

Big O Quiz
From the video: Big O Quiz
  • Has Big O clicked?
  • Pause and decide
  • Then listen

Question 1

What's the Big O of looking up a key in a dictionary? The answer is O of one. Dictionaries jump straight to the key, however many there are.

Quick check
Looking up d[key] is…

Question 2

A loop over N items, with another loop over N items inside it. What's the Big O? The answer is O of N squared, because the work multiplies.

Quick check
A loop inside a loop, both over n…

Question 3

What's three N plus five, in Big O? Drop the constants. The answer is O of N.

Quick check
3n + 5 is…

Question 4

An algorithm halves the input at every step. What's its Big O? The answer is O of log N. That's why a billion items need only about thirty steps.

Quick check
Halving each step is…

Summary

Well done. You can read the speed of code now. Next, a new section. How Python lists really work inside.

Key takeaways
  • O(1) dict lookup
  • Nested loops O(n²)
  • Halving O(log n)
Next up: Inside Python Lists — dynamic arrays