Skip to content

Instantly share code, notes, and snippets.

@clara-shin
Created May 28, 2018 09:50
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 clara-shin/b3b9b2af82562ab8e274ee3912a13632 to your computer and use it in GitHub Desktop.
Save clara-shin/b3b9b2af82562ab8e274ee3912a13632 to your computer and use it in GitHub Desktop.
이진탐색 알고리즘
function binarysearch(arr, left, right, x){
let mid = 0;
if(left > right) {
return -1;
}
mid = (left+right)/2;
if(x === arr[mid]) {
return mid;
} else if (x < arr[mid]) {
binarysearch(arr,left,right,x);
} else {
binarysearch(arr,left,right,x);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment