Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example code for plzxplain
// binary search function taken from http://rosettacode.org/wiki/Binary_search
function binary_search_recursive(a, value, lo, hi) {
if (hi < lo)
return null;
var mid = Math.floor((lo+hi)/2);
if (a[mid] > value)
return binary_search_recursive(a, value, lo, mid-1);
else if (a[mid] < value)
return binary_search_recursive(a, value, mid+1, hi);
else
return mid;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment