I've been working on a binary search of pset3 find, and I'm having an issue when I call the function again recursively. I believe that I know what the issue is, I'm just not sure how to fix it. When I call the function, it resets the values of low mid and high, because they are in the function. I tried to make a new function inside that one, but you can't declare a function there. What I need to do is to make the called function start after I declared the variables the first time, so I don't create an infinite loop just re-declaring everything. Please help me fix this problem, my code is:
`bool search(int value, int values[], int n) { if (value < 0) { return false; } int low = values[0]; int high = values[n - 1]; int mid = (low + high) / 2; //printf("Low: %i Mid: %i High %i\n", low, mid, high); if (mid == value) { return true; }
else if (mid < value) {
low = mid;
mid = (low + high) / 2;
}
else {
high = mid;
mid = (low + high) / 2;
}
//printf("Low: %i Mid: %i High %i\n", low, mid, high);
check(low, mid, high, value);
//TODO: implement a searching algorithm
}`