Question: can some one plae help me? Implement a recursive binary search function. bSearch passes in an array of integers, the size of the array, and
can some one plae help me?
Implement a recursive binary search function.
bSearch passes in an array of integers, the size of the array, and the value the function is searching for. The function should return the index where found or -1 if not found. You will want to implement a recursive helper function that passes in the array, the value to be located, and the beginning and ending of the range of values to search within.
Use the provided main function to test your search function. Be sure not to use a loop of any kind in any of the functions you write.
This is in main
thank you!
include Kiostre arm using namespace std; include Binary Search. h. int main int choice cin choice if (choice 1) int arr 11, 5, 8, 10, 14, 15 cout bsearch (arr 6, 1) endl bsearch (arr 6, 0) endl bsearch (arr 6, 15) endl bsearch (arr 6, 14) endl else if (choice 2) int arr2 178 148 99 87 -75, -42, -23, -2 cout bsearch (arr2 8, -2) endl bsearch (arr2 8, 178) endl bsearch (arr2 8, 148) endl bsearch (arr2 8, 1) endl bsearch (arr2 8, 179) endl bsearch (arr2 8, 1) endl else int arr3 1100 h; cout bsearch (arr3, 1, 100) endl. bsearch (arr3 1, 15) endl bsearch (arr3 1, 115) endl return 0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
