This is my code
#include <spl/helpers.h>
#include <stdio.h>
#include <cs50.h>
#include <stdlib.h>
int main(void);
bool search(int value, int values[], int n)
{
int lower = 0;
int upper = n - 1;
while (lower <= upper)
{
int middle = (lower + upper) / 2;
if (values[middle] < value)
{
lower = middle + 1;
}
if (values[middle] > value)
{
upper = middle - 1;
}
if (values[middle] == value)
{
return true;
}
}
return false;
}
it says that helpers is not a found library.
Also, is there anything I can do to fix/improve this code?
else if
clause instead of plainif
at second and third time place. This will reduce some useless comparisons.