Global Information Lookup Global Information

Binary search algorithm information


Binary search algorithm
Visualization of the binary search algorithm where 7 is the target value
ClassSearch algorithm
Data structureArray
Worst-case performanceO(log n)
Best-case performanceO(1)
Average performanceO(log n)
Worst-case space complexityO(1)
OptimalYes

In computer science, binary search, also known as half-interval search,[1] logarithmic search,[2] or binary chop,[3] is a search algorithm that finds the position of a target value within a sorted array.[4][5] Binary search compares the target value to the middle element of the array. If they are not equal, the half in which the target cannot lie is eliminated and 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 being empty, the target is not in the array.

Binary search runs in logarithmic time in the worst case, making comparisons, where is the number of elements in the array.[a][6] Binary search is faster than linear search except for small arrays. However, the array must be sorted first to be able to apply binary search. There are specialized data structures designed for fast searching, such as hash tables, that can be searched more efficiently than binary search. However, binary search can be used to solve a wider range of problems, such as finding the next-smallest or next-largest element in the array relative to the target even if it is absent from the array.

There are numerous variations of binary search. In particular, fractional cascading speeds up binary searches for the same value in multiple arrays. Fractional cascading efficiently solves a number of search problems in computational geometry and in numerous other fields. Exponential search extends binary search to unbounded lists. The binary search tree and B-tree data structures are based on binary search.

  1. ^ Williams, Jr., Louis F. (22 April 1976). A modification to the half-interval search (binary search) method. Proceedings of the 14th ACM Southeast Conference. ACM. pp. 95–101. doi:10.1145/503561.503582. Archived from the original on 12 March 2017. Retrieved 29 June 2018.
  2. ^ Knuth 1998, §6.2.1 ("Searching an ordered table"), subsection "Binary search".
  3. ^ Butterfield & Ngondi 2016, p. 46.
  4. ^ Cormen et al. 2009, p. 39.
  5. ^ Weisstein, Eric W. "Binary search". MathWorld.
  6. ^ Flores, Ivan; Madpis, George (1 September 1971). "Average binary search length for dense ordered lists". Communications of the ACM. 14 (9): 602–603. doi:10.1145/362663.362752. ISSN 0001-0782. S2CID 43325465.


Cite error: There are <ref group=lower-alpha> tags or {{efn}} templates on this page, but the references will not show without a {{reflist|group=lower-alpha}} template or {{notelist}} template (see the help page).

and 20 Related for: Binary search algorithm information

Request time (Page generated in 0.8002 seconds.)

Binary search algorithm

Last Update:

In computer science, binary search, also known as half-interval search, logarithmic search, or binary chop, is a search algorithm that finds the position...

Word Count : 9609

Search algorithm

Last Update:

Search algorithms can be classified based on their mechanism of searching into three types of algorithms: linear, binary, and hashing. Linear search algorithms...

Word Count : 1564

Binary search tree

Last Update:

In computer science, a binary search tree (BST), also called an ordered or sorted binary tree, is a rooted binary tree data structure with the key of each...

Word Count : 3098

Linear search

Last Update:

element vary. Linear search is rarely practical because other search algorithms and schemes, such as the binary search algorithm and hash tables, allow...

Word Count : 1010

Treap

Last Update:

binary search tree are two closely related forms of binary search tree data structures that maintain a dynamic set of ordered keys and allow binary searches...

Word Count : 3213

List of algorithms

Last Update:

search. Uniform binary search: an optimization of the classic binary search algorithm Eytzinger binary search: cache friendly binary search algorithm...

Word Count : 7843

Interpolation search

Last Update:

Interpolation search is an algorithm for searching for a key in an array that has been ordered by numerical values assigned to the keys (key values). It...

Word Count : 1844

Binary logarithm

Last Update:

they count the number of steps needed for binary search and related algorithms. Other areas in which the binary logarithm is frequently used include combinatorics...

Word Count : 4788

Multiplicative binary search

Last Update:

order used by regular binary search. Multiplicative binary search was first described by Thomas Standish in 1980. This algorithm was originally proposed to...

Word Count : 395

Dichotomic search

Last Update:

conquer algorithm. A well-known example is binary search. Abstractly, a dichotomic search can be viewed as following edges of an implicit binary tree structure...

Word Count : 264

Uniform binary search

Last Update:

Uniform binary search is an optimization of the classic binary search algorithm invented by Donald Knuth and given in Knuth's The Art of Computer Programming...

Word Count : 262

Analysis of algorithms

Last Update:

state-of-the-art machine, using a linear search algorithm, and on Computer B, a much slower machine, using a binary search algorithm. Benchmark testing on the two...

Word Count : 3682

Optimal binary search tree

Last Update:

binary search tree (Optimal BST), sometimes called a weight-balanced binary tree, is a binary search tree which provides the smallest possible search...

Word Count : 2965

Algorithm

Last Update:

than decrease and conquer algorithms. An example of a decrease and conquer algorithm is the binary search algorithm. Search and enumeration Many problems...

Word Count : 7354

Exponential search

Last Update:

computer science, an exponential search (also called doubling search or galloping search or Struzik search) is an algorithm, created by Jon Bentley and Andrew...

Word Count : 1351

Learning augmented algorithm

Last Update:

purpose machine learning can be used.[citation needed] The binary search algorithm is an algorithm for finding elements of a sorted list x 1 , … , x n {\displaystyle...

Word Count : 738

Collation

Last Update:

list. In automatic systems this can be done using a binary search algorithm or interpolation search; manual searching may be performed using a roughly...

Word Count : 2417

Nearest neighbor search

Last Update:

and usefulness of the algorithms are determined by the time complexity of queries as well as the space complexity of any search data structures that must...

Word Count : 3339

Geometry of binary search trees

Last Update:

science, one approach to the dynamic optimality problem on online algorithms for binary search trees involves reformulating the problem geometrically, in terms...

Word Count : 1621

Twenty questions

Last Update:

possibilities roughly in half each time. The process is analogous to a binary search algorithm in computer science or successive-approximation ADC in analog-to-digital...

Word Count : 2127

PDF Search Engine © AllGlobal.net