Binary search is the most efficient searching algorithm having a run-time complexity of O(log2 N) in a sorted array.
Binary search begins by comparing the middle element of the list with the target element. If the target value matches the middle element, its position in the list is returned. If it does not match, the list is divided into two halves. The first half consists of the first element to the middle element whereas the second half consists of the element next to the middle element to the last element i.e. the search interval is repeatedly divided into halves.
Let's take an example and see how binary search works and number of steps it takes as compared to linear search.