About "Binary Search":

- Binary search is used to quickly find a value in a sorted sequence, such as the range of numbers from 1 to 64.
- You go through steps continually splitting the range in two (ergo, binary) based on whether the "guess"
- Is higher or lower than the "solution". Since 32 is 2 to the 6th power, this should only take 6 guesses at a maximum.
- In fact, since 1024 is 2 to the 10th power, you should be able to determine a number between 1 and 999 in just 10 guesses!
- This is not just a parlor trick, it could for instance get children interested in the logic driving computer programs.
- If they are asked how many tries it should take and they divide 1000 by 2 and answer 500 based with the idea there's a fifty/fifty chance
- Then at least they are thinking logically and can be taught the technique, though 1 to 64 might be more managable than 1 to 999
- Now consider that a billion is a bit less than 2 to the 30th power, meaning that if a billion pieces of data are sorted in some way
- A computer program can find that one piece of data from a billion in just 30 tries. This is what drives "database indexes"
- A caution though, in order to ensure the speed gains that a database index can provide, all the indexed data must fit into RAM
- If there is not enough such memory, slow "swapping to disk" might be necessary, and thus might negate some speed benefits of index usage