Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Must be done in for C++ in Visual Studio Modify the binarySearch function presented in the chapter so it searches an array of strings instead
Must be done in for C++ in Visual Studio
Modify the binarySearch function presented in the chapter so it searches an array of strings instead of an array on ints. Test the function with the driver program. Use the Program 8-8 as a skeleton to complete. (The array must be sorted before the finery search will work.//The binarySearchBench function performs a binary//search on array for value. It returns the number of//comparisons made.//int binarySearchBench (int array [], int size, int value)} bool found = false;//The found flag, initialized to false int first = 0//To hold the index value of the first element. int middle;//To hold the index value of the mid point int last = size -1;//To hold the index value of the last element int comparisons = 0;//To hold the number of comparisons.//Search while the value has not been found, //and the index is still in the array bounds. while (!found & & first value) last = middle -1; Determine if the value is in the upper half else first = middle + 1}//Return the number of comparisons. comparisonsStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started