In this lesson
- It starts with a question. Mere thinks of a whole number from 1 to 100. After each guess she says only “higher” or “lower”. Ravi wants to be sure of finding it in as few guesses as possible. What should he guess first?
- The idea you will find. Look in the middle, then throw away the half that cannot hold it. — You tapped 8 because it split 1 to 15 evenly. Each look leaves at most half of what was there: 15, then 7, then 3, then 1, so four looks always find the number. It only works because the numbers are in order — that is what makes “higher” or “lower” rule out a whole half.
- How you learn it. By doing: a number line, a slider.
- Length. 6 short steps. Progress saves on this phone.
Part of Python: Sorting & Searching
Sorting, searching and counting — and knowing which approach survives a big list.