int sizeOfArray; //size of array
int* array; //contains your array
bool recursiveBinaryFind(int searchNum){
//pass 0 as the low pasotion and the size of the array as the highest search range position
return recursiveBinaryFind(searchNum, 0, sizeOfArray);
}
bool recursiveBinaryFind(int searchNum, int lowBound, int highBound){
//If the low position is greater than the high, quit we looped through everything and didn\'t find our value
if (lowBound > highBound) return false;
//Find the middle position
int middle = (lowBound + highBound)/2;
//Did we find our value?
if (array[middle] == searchNum) {
return true;
} else if (array[middle] > searchNum) {
//Search the lower search range half
return recursiveBinaryFind(searchNum, lowBound, middle - 1);
} else {
//Search the higher search range half
return recursiveBinaryFind(searchNum, middle + 1, highBound);
}
}