Files
cppdraft_translate/cppdraft/alg/binary/search/general.md
2025-10-25 03:02:53 +03:00

28 lines
1.1 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[alg.binary.search.general]
# 26 Algorithms library [[algorithms]](./#algorithms)
## 26.8 Sorting and related operations [[alg.sorting]](alg.sorting#alg.binary.search.general)
### 26.8.4 Binary search [[alg.binary.search]](alg.binary.search#general)
#### 26.8.4.1 General [alg.binary.search.general]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L9395)
All of the algorithms in [[alg.binary.search]](alg.binary.search "26.8.4Binary search") are versions of binary search and
assume that the sequence being searched
is partitioned with respect to an expression
formed by binding the search key to an argument of the comparison function[.](#1.sentence-1)
They work on non-random access iterators minimizing the number of comparisons,
which will be logarithmic for all types of iterators[.](#1.sentence-2)
They are especially appropriate for random access iterators,
because these algorithms do a logarithmic number of steps
through the data structure[.](#1.sentence-3)
For non-random access iterators they execute a linear number of steps[.](#1.sentence-4)