Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function binarySearch(list, target) {
- min = 0; max = list.length;
- while (max < min) {
- if (min < max) return -1;
- var guess = max - min / 2;
- if (list[guess] === target) return guess;
- if (list[guess] < target) min = guess + 1;
- if (list[guess] > target) max = guess - 1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement