Intuition
Binary search looks for a specific value, which we refer to as a key in a sorted list. For example, it could be looking for a specific word in a dictionary, the word in this situation is the key, and the dictionary is the sorted list (it’s in alphabetical order).
- Binary search takes in 4 parameters or input values, a lower bound position (which it will not search below), and an upper bound position (which it will not search above), a sorted list of values, and a key to search for.
- If it finds the key it outputs the position of the key in the list.
- If it does not find the key, it indicates that it didn't find it.