Boss lesson · Unit 01
Twenty questions
Halving makes a million shrink to 20
What you practise
- Repeated halving is O(log n)
- Guess a number in 1..1,000,000
- Rank the growth classes
- A first look at space
Try a question from this lesson
Pick one
I pick a number from 1 to 1,000,000 and answer "higher" or "lower". Always guessing the middle, how many guesses do you need at most?
Hint
Each guess can cut the remaining range in half. How many halvings does a million survive?
Correct answer
About 20
Why
Each guess halves what is left, and a million halves down to 1 in about 20 steps (2²⁰ is 1,048,576). Guessing 1, 2, 3… would be linear: up to a million guesses.
The ideas
Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.
Concept
O(log n): halve until done
If every step throws away half of what is left, the number of steps is log₂ n: how many times n can be halved before reaching 1.
Logarithms grow absurdly slowly. A thousand items take about 10 steps, a million about 20, a billion about 30. Doubling the input adds a single step.
Concept
The growth ladder
From slowest-growing to fastest:
O(1), O(log n), O(n), O(n log n), O(n²), O(2ⁿ)
For n = 1,000,000: log n is about 20, n log n about 20 million, and n² a trillion. O(2ⁿ) doubles with every single extra item.
9 more exercises in the app
- 2× type the answer
- 1× fill the blanks
- 1× order the lines
- 3× multiple choice
- 1× match the pairs
- 1× true or false
Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.