Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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