Skip to content

Instantly share code, notes, and snippets.

@benmak11
Created February 26, 2014 02:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benmak11/9222489 to your computer and use it in GitHub Desktop.
Save benmak11/9222489 to your computer and use it in GitHub Desktop.
{
"libraries": [],
"mode": "javascript",
"layout": "fullscreen mode (vertical)",
"resolution": "reset"
}
/* css goes here */
<!-- html goes here -->
key = 'c';
array = ['a', 'b', 'c', 'd'];
var low = 0;
var high = array.length - 1;
while (1) {
var mid = floor((low + high)/2);
var value = array[mid];
if(value < key) {
low = mid + 1;
}
else if (value > key) {
high = mid - 1;
}
else {
return mid;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment