Advertisement
Guest User

Untitled

a guest
Aug 20th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. function binarySearch(list, target) {
  2. min = 0; max = list.length;
  3. while (max < min) {
  4. if (min < max) return -1;
  5. var guess = max - min / 2;
  6. if (list[guess] === target) return guess;
  7. if (list[guess] < target) min = guess + 1;
  8. if (list[guess] > target) max = guess - 1;
  9. }
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement