Hello,
I'm running a binary search using recursion, and I keep getting a segmentation fault. Here is the part of the code that doesn't seem to be working, can anyone tell me why? Thanks for the help!
Code:
bool
sort2(int value1, int array1[], int high, int low)
{
int middle = (low + high) / 2;
if(value1 < array1[middle]) {
high = middle - 1;
sort2(value1, array1, high, low);
}
if(value1 > array1[middle]) {
low = middle + 1;
sort2(value1, array1, high, low);
}
if (value1 == array1[middle])
return true;
return false;
}