Search by halves: 12 levels of binary search, left and right bounds and targets. The most fundamental search algorithm game for interviews.
Binary search works on a sorted array. At each step, we look at the middle element (mid). If the target is larger, search the right. If smaller, search the left.
With 16 elements, binary search needs at most 4 steps (log₂ 16 = 4). Linear search could need up to 16 steps.
Sometimes the target isn't in the array. Binary search ends when the search area is empty (low > high). When that happens, we know the target isn't there.
A variation of binary search: if the target isn't found, determine where the target should be inserted. The insert position = the value of low when the search ends.