mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-11-10 11:09:43 +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
295fb99242
commit
8e37e8ff7a
@ -21,7 +21,7 @@ function binarySearch(sortedArray, startIndex, endIndex, seekElement, comparator
|
|||||||
}
|
}
|
||||||
// If element is smaller than middleIndex, then it can only be present n left subarray
|
// If element is smaller than middleIndex, then it can only be present n left subarray
|
||||||
if (comparator.greaterThan(sortedArray[middleIndex], seekElement)) {
|
if (comparator.greaterThan(sortedArray[middleIndex], seekElement)) {
|
||||||
return binarySearch(sortedArray, startIndex, middleIndex-1, seekElement, comparatorCallback);
|
return binarySearch(sortedArray, startIndex, middleIndex - 1, seekElement, comparatorCallback);
|
||||||
}
|
}
|
||||||
// Else the element can only be present in right subarray
|
// Else the element can only be present in right subarray
|
||||||
return binarySearch(sortedArray, middleIndex + 1, endIndex, seekElement, comparatorCallback);
|
return binarySearch(sortedArray, middleIndex + 1, endIndex, seekElement, comparatorCallback);
|
||||||
|
Loading…
Reference in New Issue
Block a user