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