I have some problems with Binary search. Check50 works fine for every case except this one:
:( finds 42 in {42,43,44} \ expected an exit code of 0, not 1 I got no clue why this happens :(
I followed Zamyla Chan's video tutorial and implemented it with a While loop. My code is this:
while (n > 0)
{
int min = 0;
int max = n;
int mid = ((max + min) / 2) + 1;
if (values[mid] == value)
{
return true;
}
else if (values[mid] > value)
{
max = mid - 1;
}
else if (values[mid] < value)
{
min = mid + 1;
}
n = max - min;
}
return false;
}