Created
May 28, 2018 09:50
-
-
Save clara-shin/b3b9b2af82562ab8e274ee3912a13632 to your computer and use it in GitHub Desktop.
이진탐색 알고리즘
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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