Question: This also uses the solutions for fileIO.cpp and checkArray.cpp from my last post. (Exercise) Create - searchArray1.cpp In this part of the lab, you will

 This also uses the solutions for fileIO.cpp and checkArray.cpp from my

This also uses the solutions for fileIO.cpp and checkArray.cpp from my last post.

(Exercise) Create - searchArray1.cpp In this part of the lab, you will create a recursive function that searches for a key in an array with a binary search algorithm. Revisit lecture 4 for the concept of the binary search algorithm. All you need to do is to repeat splitting an array by half and compare the key to the value of the middle element. In the main function: Input an array from a file. created from the previous exe code that you wrote so far (exercise 2) *Call function (checkArraySort) to check if the array is sorted. So far, you can use the code you rcises. .Exit program if the array is not sorted, otherwise continue to the next steps. Once again, you can use the Prompt the user to input the search key (k) * Call function (binarySearchR) to search for the key recursively .Output your search result: o "Found key "!" if the key was found, where is the search key string (notice the quotes around the key string that must be printed) and is the index of the first element where the key was found. o "The key "" was not found in the array!" if the key was not found Your binarySearchR function will return an integer value i as the first index in the array A where the key is found (or -1 in key is not found), and it will take the following arguments: a string array A (again, it is a pointer) the number of elements in the array the key to search (a string) * * Before writing r binarySearchR function, think about the algorithm and write its pseudocode in file

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!