Image for Binary search algorithm

Binary search algorithm

Binary search is an efficient method for finding a specific item in a sorted list. It works by repeatedly dividing the list in half to narrow down the search. First, it compares the target item with the middle element. If they match, the search ends successfully. If the target is smaller, the search continues on the lower half; if larger, on the upper half. This process repeats, halving the search range each time, until the item is found or the range becomes empty. Binary search is quick because it reduces the number of comparisons needed to find an item in a sorted collection.