Guess the number
I am thinking of a whole number from 1 to 1000. After each guess I tell you "higher", "lower" or "correct".
With the best strategy, what is the maximum number of guesses you could need?
Show hint
Each guess should cut the remaining range in half. How many times can you halve 1000 before only one number is left?
Show solution
10 guesses.
With k guesses, binary search can tell apart at most 2k − 1 numbers. 29 − 1 = 511 is too few, while 210 − 1 = 1023 covers all 1000. This is why binary search is O(log n).
Want a problem like this every day? See today's problem and keep a streak going.