bool search(int value, int values[], int n)
{
int midpoint = n / 2;
int startpoint = 0;
int endpoint = n - 1;
// if the midpoint doesn't equal the vales we're looking for, repeat this loop
while (values[midpoint] != value)
{
// if value is smaller than midpoint
if (value < values[midpoint])
{
endpoint = midpoint - 1;
midpoint = (int) ((endpoint - startpoint + 1) / 2);
}
// if value is larger than midpoint
else if (value > values[midpoint])
{
startpoint = midpoint + 1;
midpoint = (int) ((endpoint - startpoint + 1) / 2);
}
if (endpoint - startpoint == 0 && values[startpoint] != value)
{
return false;
}
}
return true;
}
Read over it a couple times and watched the walkthrough. Not sure what's wrong :/