// TODO: implement a searching algorithm
if(n <= 0)
{
return false;
}
int end = n;
int start = 0;
int middle = (start + end)/2;
int found = 0;
while(found == 0)
{
if(value == values[middle])
{
found = 1;
return true;
}
else if(value > values[middle])
{
start = middle;
}
else if(value < values[middle])
{
end = middle;
}
if(values[start] == value)
{
found = 1;
return true;
}
middle = (start + end)/2;
if(end - start == 1)
{
found = 2;
return false;
}
}
return false;
// TODO: implement a sorting algorithm
int checkArray[65356] = {0};
for(int i = 0; i < 11 ; i++)
{
for(int j = 0; j < n; j++)
{
if(values[i] == j)
{
checkArray[j] += 1;
}
}
}
int counter = 0;
int repeats;
for(int i = 0; i < n; i++)
{
if(checkArray[i] > 0)
{
repeats = checkArray[i];
while(repeats > 0)
{
values[counter] = i;
repeats -= 1;
counter += 1;
}
}
}
for(int i = 0; i < 11; i++)
{
printf("%i\n", values[i]);
}
return;
My code for find(more) in pset3 is not finding any numbers from generate. I have copied the same code into a different file to make it search from a pre defined array and that works perfectly. However, when I run find, the code doesn't find anything.
Any help would be appreciated.