Changes to Binary search algorithm
TechWritereditor · 5 Dec 2026, 07:26 · “New page”
+ added − removed (first version)
Title
Removed:
Added: Binary search algorithm
Short description
Removed:
Added: Method for finding a value in a sorted list
Type
Removed:
Added: technology
Summary
Removed:
Added: Binary search is a method for finding a value in a sorted list by repeatedly halving the part of the list that could contain it. It needs only about 20 comparisons to search a million items.
Fact box
Removed:
Added: Type: Search algorithm
Added: Requires: Sorted data
Added: Time complexity: O(log n)
Added: First mentioned: 1946 (John Mauchly, Moore School Lectures)
Added: Strategy: Divide and conquer
Article
Added: The **binary search algorithm** is a method for finding a value in a sorted array by repeatedly halving the search interval.[^1] It is one of the simplest examples of the divide-and-conquer approach and is used inside other techniques such as binary insertion sort and suffix arrays.[^1]
Added: ## How it works
Added:
Added: The search begins with the whole list and compares the target with the middle item. If they match, the search ends; if the target is smaller, the search continues in the lower half, otherwise in the upper half.[^1][^2] This repeats until the value is found or the remaining interval is empty, which means the value is not present.[^1] The list must be sorted in advance, otherwise the result cannot be trusted.[^2]
Added:
Added: Because each step discards half of the remaining items, a search of *n* items needs at most about 1 + log2 *n* comparisons: roughly 20 for a million items and 30 for a billion. Doubling the size of the list adds only one comparison.[^2] A linear search, which checks items one by one, has a cost that grows in direct proportion to the size of the list.[^2] On a linked list, however, binary search still makes only a logarithmic number of comparisons but must step through the list, so it is no faster than a linear search.[^1]
Added:
Added: ## History
Added:
Added: John Mauchly made the first recorded mention of binary search in 1946, during the Moore School Lectures on electronic computing.[^3] Early versions worked only on lists whose length was a power of two; in 1960 Derrick Henry Lehmer published a version without that restriction.[^3] Writing correct code for the method proved surprisingly difficult: Jon Bentley's *Programming Pearls* noted that although the first binary search was published in 1946, the first version that worked for all list sizes did not appear until 1962.[^4]
Added:
Added: In 2006 Joshua Bloch of [[Google]] reported that the version in the [[Java (programming language)]] library, and many others, contained a bug that had gone unnoticed for about nine years. Calculating the midpoint as (low + high) / 2 can overflow when the array has around a billion or more elements, producing a negative index.[^4] Safer forms such as low + (high − low) / 2 avoid the problem.[^1][^4]
Added:
Added: ## See also
Added: - [[Merge sort]]
Added: - [[Quicksort]]
Added: - [[Hash table]]
Added: - [[John Mauchly]]
Sources
Removed:
Added: binary search – Dictionary of Algorithms and Data Structures | https://xlinux.nist.gov/dads/HTML/binarySearch.html | National Institute of Standards and Technology | 2022-04-21
Added: Binary Search (15-110 lecture, Unit 5) | https://www.cs.cmu.edu/~15110-n15/lectures/unit05-2-BinarySearch.pdf | Carnegie Mellon University
Added: Data Structures History (CSC 162 lecture) | https://www.cs.rochester.edu/~hbeadle/csc162/_static/lectures/ds_history.pdf | University of Rochester
Added: Extra, Extra - Read All About It: Nearly All Binary Searches and Mergesorts are Broken | https://research.google/blog/extra-extra-read-all-about-it-nearly-all-binary-searches-and-mergesorts-are-broken/ | Google Research | 2006-06-02
Categories
Removed:
Added: Algorithms
Other names
Removed:
Added: Binary search
Added: Half-interval search
Added: Binary chop