Question: In class, we briefly mentioned how to perform a binary search on an array. Note that this approach is more efficient than any of the

In class, we briefly mentioned how to perform a binary search on an array. Note that this approach is more efficient than any of the other searching approaches we discussed. As a reminder, the algorithm for the iterative version of binary search, where we are given an array array of size n and a target, is given below:

 In class, we briefly mentioned how to perform a binary search

*******THIS SHOULD BE DONE IN C CODE, NOT C++*******

Function BINARY-SEARCH(array, n, target) 1: Let bottom 0 2: Let top = n-1. 3: Let found = false. 4: Let index be the index of array. 5: while (bottom target) then Let top be middle -1. else 12 13: Let bottom be middle + 1. end if 15 end if 16: end while You are asked to turn this into a recursive program. Write a function called binary_search that implements the recursive algorithm for an array of integers. Hint: In class, most of our examples had 1 to 2 parameters, and one of the arguments slightly changed each time we called the function. For this program, you will need more than two parameters, and more than one argument will change each time we call the function As for the array itself, assume the array has 10 items, and the program asks the user to enter the 10 integers Also, I highly suggest you spend some time thinking about how to implement the recursive algorithm before you start coding

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!