Binary search: Difference between revisions
From Coderwiki
More actions
new |
link to Collection |
||
| Line 1: | Line 1: | ||
A '''binary search''' is a [[search algorithm]] which works by '''discarding''' half of an [[array]] or [[ | A '''binary search''' is a [[search algorithm]] which works by '''discarding''' half of an [[array]], [[list]] or other [[collection]] in order to speed up search time. | ||
== Advantages of a binary search == | == Advantages of a binary search == | ||
| Line 9: | Line 9: | ||
* [[Performance|Slower]] than a [[linear search]] on '''very''' small datasets | * [[Performance|Slower]] than a [[linear search]] on '''very''' small datasets | ||
* Still very simple, but slightly more complex to implement | * Still very simple, but slightly more complex to implement | ||
* The [[ | * The [[collection]] '''must''' be [[Sort algorithm|in order]] | ||
Latest revision as of 07:56, 13 August 2025
A binary search is a search algorithm which works by discarding half of an array, list or other collection in order to speed up search time.
Advantages of a binary search
edit edit source- Almost always faster than a linear search
Disadvantages of a binary search
edit edit source- Slower than a linear search on very small datasets
- Still very simple, but slightly more complex to implement
- The collection must be in order