mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-09-20 07:43:04 +08:00
Update src/algorithms/search/exponential-search/exponentialSearch.js
Co-authored-by: codacy-production[bot] <61871480+codacy-production[bot]@users.noreply.github.com>
This commit is contained in:
parent
8e37e8ff7a
commit
dd1843f0ae
@ -48,7 +48,7 @@ export default function exponentialSearch(sortedArray, seekElement, comparatorCa
|
|||||||
// Find range for binary search by repeated doubling
|
// Find range for binary search by repeated doubling
|
||||||
let range = 1;
|
let range = 1;
|
||||||
while (range < length && comparator.lessThanOrEqual(sortedArray[range], seekElement)) {
|
while (range < length && comparator.lessThanOrEqual(sortedArray[range], seekElement)) {
|
||||||
range = range * 2;
|
range *= 2;
|
||||||
}
|
}
|
||||||
// Call binary search for the found range.
|
// Call binary search for the found range.
|
||||||
return binarySearch(sortedArray, range/2, Math.min(range, length - 1), seekElement, comparatorCallback);
|
return binarySearch(sortedArray, range/2, Math.min(range, length - 1), seekElement, comparatorCallback);
|
||||||
|
Loading…
Reference in New Issue
Block a user