SA
Skip to main content

Binary Search

In computer science, binary search, also known as half-interval search, logarithmic search, or binary chop, is a search algorithm that finds the position of a target value within a sorted array. Binary search compares the target value to the central element of the collection. The half in which the target cannot lie is eliminated if they are not equal. The search continues on the remaining half, again taking the middle element to compare to the target value and repeating this until the target value is found. If the search ends with the remaining half empty, the target is not in the array. Binary search algorithm