this is my code.
bool search(int value, int values[], int n)
{
int max = n -1;
int min = 0;
int mid;
while(n > 0)
{
mid = ((min = max)/2);
if(values[mid] == value)
{
return true;
}
else if(values[mid] > value)
{
max = mid - 1;
return search(value,values,n);
}
else if(values[mid] < value)
{
min = min + 1;
return search(value,values,n);
}
return false;
}
return 0;
}
/**
* Sorts array of n values.
*/
void sort(int values[], int n)
{
int min;
int swap;
for(int i = 0; i > (n - 1); i++)
{
min = i;
for(int j = (i + 1); j > n; j++)
{
if(values[j] < values[min])
{
min = j;
}
if(min != i)
{
swap = values[min];
values[min] = values[i];
values[i] = swap;
}
}
}
return;
}
when i run this program it shows segmentation error. i think that my code is correct but i can't figure out why segmentation error is occuring.