To invoke the preceding ExponentialSearch() function, we can use the following main() function code:
int main(){ cout << "Exponential Search" << endl; // Initialize a new array int arr[] = {8, 15, 23, 28, 32, 39, 42, 44, 47, 48}; int arrSize = sizeof(arr)/sizeof(*arr); // Define value to be searched int searchedValue = 39; // Find the searched value using blockIndex Search int i = ExponentialSearch(arr, arrSize, searchedValue); // Notify user the result // if the return is not -1, // the searched value is found if(i != -1) { cout << searchedValue << " is found in index "; cout << i << endl; } else { cout << "Could not find value " << searchedValue; cout << endl; } return 0;}
If we build and run the ...