Searching
New idea
Guess my number, 1 to 1,000
I'm thinking of a number from 1 to 1,000. After each guess I'll only say "higher" or "lower". Guessing 1, 2, 3, ... could take 1,000 tries. A smart player needs about 10.
The slow way is linear search. Check the items of an array (a list) one by one from the start until you find it. With 1,000 items, the worst case is 1,000 checks.
The smart way needs one condition: the array must be sorted (in order). You'll try it next.