I have just started Pset3. I was going well until as per specification I read this
Re-write search in such a way that it uses linear search, returning
true
ifvalue
is invalues
andfalse
ifvalue
is not invalues
. Take care to returnfalse
right away ifn
isn’t even positive.
I was like what am I suppose to do now? Still having no idea what to do I wrote this code in search function in helpers.c
bool search(int value, int values[], int n)
{
if (n < 0)
{
return false;
}
for (int i = 0 ; i < n; i++)
{
if (values[i] == value)
{
return true;
}
else
{
return false;
}
}
}
But didn't get the needle, so the question here is what am I supposed to do here? Am i going in the right direction? Any help or hint would really be appreciated.