mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-06 01:18:23 +08:00
Exponential Search : Fix 'value' is not defined
error .
This commit is contained in:
@ -9,12 +9,12 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function binarySearch (arr, x, floor, ceiling) {
|
function binarySearch (arr, value, floor, ceiling) {
|
||||||
// Middle index
|
// Middle index
|
||||||
const mid = Math.floor((floor + ceiling) / 2)
|
const mid = Math.floor((floor + ceiling) / 2)
|
||||||
|
|
||||||
// If value is at the mid position return this position
|
// If value is at the mid position return this position
|
||||||
if (arr[mid] === x) {
|
if (arr[mid] === value) {
|
||||||
return mid
|
return mid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user