How does binary search reduce the number of items that must be checked?

Created from Britannica articles using AI. AI can make mistakes, so verify using Britannica articles.

In computer science, a binary search reduces the number of items that must be checked by leveraging the fact that the list is already sorted.12

Instead of checking each element sequentially, the algorithm repeatedly divides the search space in half. By comparing the target value to the middle element of the current range, the algorithm can determine whether the target lies in the first or second half of the remaining items. It then discards the half that cannot contain the target and repeats this process with the remaining portion.12

Because the list is halved at each step, the number of operations required grows with the logarithm of the total number of items (n) in base 2, rather than proportionally to n. This results in a time complexity of O(logn), which is significantly more efficient than linear search methods that must check every item.1