binary-search
unknown
c_cpp
a year ago
318 B
12
Indexable
int Search(int a[], int start, int last, int item)
{
int mid;
if(last >= start)
{
mid = (start + last)/2;
if(a[mid] == item){
return mid+1;
}
else if(a[mid] < item){
return Search(a,start,mid+1,item);
}
else{
return Search(a,mid-1,last,item);
}
}
return -1;
}Editor is loading...
Leave a Comment