-
-
Save eengineergz/c82c00a4bcba4b69b7d326d6cad3ac8c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function binarySearch(array, target) { | |
if (array.length === 0) return false; | |
let midPt = Math.floor(array.length / 2); | |
if (array[midPt] === target) { | |
return true; | |
} else if (list[midPt] > target) { | |
return binarySearch(list.slice(0, mid), target); | |
} else { | |
return binarySearch(list.slice(midPt + 1), target); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment