Binary search is a search algorithm that finds the position of a target value within a sorted array by repeatedly comparing the target to the array's middle element and discarding the half of the array that cannot contain it. Because each comparison eliminates half the remaining elements, the algorithm needs at most about the logarithm, base two, of the array's size in comparisons, far fewer than the linear scan a plain search over an unsorted list requires. An early refinement in the algorithm's own history is Hermann Bottenbruch's implementation, published in 1962, which removed an unnecessary equality check present in earlier versions and set the form most textbooks now teach. Binary search requires the array to already be sorted, which is the tradeoff against its speed: unsorted data must be sorted first, or searched by a slower linear method instead.
Facts
Time Complexity
Time Complexity (category)Logarithmic Time -- O(log n) 1 Classification
Design Technique Connections
In Field
Source Binary search (Wikipedia)
Uses Design Technique
Sources
1. Binary Search Algorithm (Wikipedia)
Wikipedia infobox: time complexity logarithmic
logarithmic
Wikipedia: design technique divide-and-conquer
divide-and-conquer
View the SourceBinary search (Wikipedia)
In Field: Algorithms and Complexity Theory, Lead sentence
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.
In Group: Searching Algorithms for Ordered Lists, Lead section
finds the position of a target value within a sorted array
View the SourceReader Challenges (0)
No disputes yet. Spotted an error or a better source? Open the first one.
Sign in to dispute this or suggest a correction.