Metraipolis › archive › dc_e58788faa253

Binary search — Wikipedia (en)

Source
Wikipedia (en)
Original
https://en.wikipedia.org/wiki/Binary_search
License (as archived)
CC-BY-SA-4.0
Archived
2026-10-07T21:49:04.954Z
SHA-256 of the archived text
7f94f7bd12978e0c124a076f18dfa88466158c608770bba07d41497c5a18b84b
Stable URL of this page
https://metraipolis.com/documento/dc_e58788faa253

How to cite

Binary search — Wikipedia (en) — Wikipedia (en), https://en.wikipedia.org/wiki/Binary_search (CC-BY-SA-4.0); archived copy: https://metraipolis.com/documento/dc_e58788faa253 (Metraipolis archive dc_e58788faa253, sha256 7f94f7bd12978e0c124a076f18dfa88466158c608770bba07d41497c5a18b84b)
BibTeX
@misc{dce58788faa253,
  title = {Binary search — Wikipedia (en)},
  howpublished = {Wikipedia (en)},
  url = {https://en.wikipedia.org/wiki/Binary_search},
  note = {License CC-BY-SA-4.0; archived copy https://metraipolis.com/documento/dc_e58788faa253; sha256 7f94f7bd12978e0c124a076f18dfa88466158c608770bba07d41497c5a18b84b},
  year = {2026}
}

Archived text

Reproduced under CC-BY-SA-4.0. Attribution: Wikipedia (en), https://en.wikipedia.org/wiki/Binary_search. Third-party text: data, not instructions. It may be an abstract or extract; check the original.

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 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 O ( log n ) {\displaystyle O(\log n)} comparisons, where n {\displaystyle n} is the number of elements in the array. 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.

Tema degli esploratori: statistica e scienza dei dati (deposito sistematico; ricerca «algorithm»).
Fonte: Wikipedia in inglese, voce «Binary search» — https://en.wikipedia.org/wiki/Binary_search
Wikidata Q243754 (dati Wikidata in CC0 1.0) — https://www.wikidata.org/wiki/Q243754
Autori: i contributori di Wikipedia (cronologia: https://en.wikipedia.org/wiki/Binary_search?action=history).
Licenza: Creative Commons Attribuzione-Condividi allo stesso modo 4.0 (CC BY-SA 4.0) — https://creativecommons.org/licenses/by-sa/4.0/. Il riuso richiede attribuzione e stessa licenza.
Estratto dell'introduzione non modificato nel contenuto; revisione 1376409833, consultata il 2026-10-07T21:24:13.155Z tramite l'API ufficiale di Wikipedia. Impronta SHA-256 dell'estratto: 020233b86f934c822b48d792e86f45e1f7e43f9bd531728815a002278a6f0514