A binary search searches sorted lists using a divide and conquer technique. On each iteration the search domain is cut in half, until the result is found. The computational complexity of a binary search is O(log n).
This module implements several Binary Search algorithms using XS code for optimal performance. You are free to use this module directly, or as a plugin for the more general List::BinarySearch.
The binary search algorithm implemented in this module is known as a Deferred Detection Binary Search. Deferred Detection provides stable searches. Stable binary search algorithms have the following characteristics, contrasted with their unstable binary search cousins:
return the lowest-indexed matching element. An unstable binary search would return the first one found, which may not be the chronological first.
searches may stop once the target is found, but in the worst case are still O(log n). In practical terms, this difference is usually not meaningful.
given pair of data elements per iteration, where unstable binary searches require two comparisons per iteration.
better "best case" performance, the fact that a stable binary search gets away with fewer comparisons per iteration gives it better performance in the worst case, and approximately equal performance in the average case. By trading away slightly better "best case" performance, the stable search gains the guarantee that the element found will always be the lowest-indexed element in a range of non-unique keys.
Package Version | Update ID | Released | Package Hub Version | Platforms | Subpackages |
---|---|---|---|---|---|
0.09-bp156.3.3 info | GA Release | 2023-12-07 | 15 SP6 |
|
|
0.09-bp155.2.11 info | GA Release | 2023-05-17 | 15 SP5 |
|
|
0.09-bp154.1.21 info | GA Release | 2022-05-09 | 15 SP4 |
|
|
0.09-bp153.1.16 info | GA Release | 2021-03-06 | 15 SP3 |
|
|
0.09-bp152.1.9 info | GA Release | 2020-04-16 | 15 SP2 |
|
|