this is my code for binary search.
bool binary(int key, int array[], int min, int max);
bool search(int value, int values[], int n)
{
if( n< 0)
{
return false;
}
else
{
return binary(key,array,min,max);
}
}
bool binary(int key, int array[], int min, int max)
{
int mid = (min + max)/2;
if( array[mid] == key)
{
return true;
}
else if( array[mid]> key)
{
return binary(key,array,min,mid-1);
}
else if(array[mid]< key)
{
return binary(key,array,mid+1,max);
}
return false;
}
void sort(int values[], int n)
{
int min;
int swap;
for(int i = 0; i > n; i++)
{
min = i;
for(int j = 0; j == n; j++)
{
if(values[j] > values[min])
{
min = j;
if (min != i)
{
swap = values[min];
values[min] = values[i];
values[i] = swap;
}
}
}
}
return;
}
after compiling it shows error saying that - helpers.c:31:22: error: use of undeclared identifier 'key' return binary(key,array,min,max); ^ helpers.c:31:26: error: use of undeclared identifier 'array' return binary(key,array,min,max); ^ helpers.c:31:32: error: use of undeclared identifier 'min' return binary(key,array,min,max); ^ helpers.c:31:36: error: use of undeclared identifier 'max' return binary(key,array,min,max); even though i have defined them above in line 1. why this error is coming? also is this way of making the code in accordance with condition of pset3 as they have asked to not change the defination of search. please help me.