I've been looking over and over this for a while but I can't seem to understand what's wrong with it.
I run the ./find and the terminal and this is what I see:
My code is as follows:
bool search(int value, int values[], int n)
{
if (value < 0)
{
return false;
}
else
{
int max = n - 1;
int min = 0;
int middle;
while (max >= min)
{
middle = (min + max) / 2;
if (values[middle] == value)
{
return true;
}
else if (values[middle] > value)
{
max = values[middle - 1];
}
else if (values[middle] < value)
{
min = values[middle + 1];
}
}
return false;
}
I'd appreciate any kind of help since I feel very stuck at the moment.
Thank you!