binary search base case

binary
problem
search

#1

if(low==high)
{
if(a[low]==key)
{
return low;
}
else
{cout<<“THE value doesnt exist”;
return nill;
}

why is this base case not working for binary search


#2

it might be a case that in while loop , the low index has passed (become greater) ,than ‘high’ index , therefore , i guess your if condition is not getting satisfied and hence , not giving desired output.


#3

can u please provide a simple test case ?? i mean what u are saying is the standard recursive definition but i am just curious to know why this case isnt working


#4

can u give ur whole code…or maybe the whole of ur binary search implementation!!!