I've been getting strange compiler errors on this binary search algorithm. I get a warning that control reaches end of non-void function
. What does this mean?
int binary(int val, int sorted[], int low, int high) {
int mid = (low+high)/2;
if(high < low)
return -1;
if(val < sorted[mid])
return binary(val, sorted, low, mid-1);
else if(val > sorted[mid])
return binary(val, sorted, mid+1, high);
else if(val == sorted[mid])
return mid;
}