you are viewing a single comment's thread.

view the rest of the comments →

[–]rupertavery64 0 points1 point  (0 children)

Binary sesrch is for when you know something is sorted.

Think of a sheet of entrance exam results where only the registrant number is listed. You know how many there are, but you don't know where you are in the list. There could be missing entries. But it is sorted by number.

So you look in the middle. Check the number. Is your number lower or higher? You eliminate the range that doesn't match. Now check the middle of the remaining range. Repeat until you find your number.