Created
September 30, 2019 13:48
-
-
Save ahmedshahriar/c6082f3a65db71f430eb41c608fe1c02 to your computer and use it in GitHub Desktop.
This file contains 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
int searchBinary(int arrayList[],int findNum,int first , int last ){ | |
while(first<=last){ | |
int middle =( last+first)/2; | |
if(arrayList[middle]==findNum) | |
return middle; | |
else if (arrayList[middle]<findNum) //ignore left half | |
return searchBinary(arrayList,findNum,middle+1,last); | |
else | |
return searchBinary(arrayList,findNum,first,middle-1); | |
} | |
return -1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment