check50 gives me all smiles, but when I run the test code ./generate 1000 50 | ./find 127 or 128 they both return "Found needle in haystack". How is that possible? And also, can I be sure my code is right based on the results from check50 even though the debugging test they suggested themselves fails in one of the scenarios? Please help me.
Here is my basic implementation for bool search(int value, int values[], int n), considering that min is 0, max is n - 1, and middle is min + max / 2:
//pseudo code
for loop int i is 0; i less than n; i++
{
if max less than min just return 1;
else
if values[i] less than value
min is middle + 1;
else if values[i] greater than value
max is middle - 1;
else
just return middle;
}
return 0;
And here is my basic implementation of void sort(int values[], int n):
for loop int i is 0; i less than n; i++
{
for loop int j is i; j less than *values; j++
{
if values[j] less than values[i]
{
swapper is values[j];
values[j] is values[i];
values[i] is swapper;
}
}
}