Question: Please help me. Using C ++ Lenguage. Consider the following function 9 bint binarySearch(int myArray[], int length, int element) { int first = m; int

 Please help me. Using C ++ Lenguage. Consider the following function

9 bint binarySearch(int myArray[], int length, int element) { int first =

Please help me. Using C ++ Lenguage.

Consider the following function 9 bint binarySearch(int myArray[], int length, int element) { int first = m; int last = length - 1; int mid; bool found = false; while (first element) last = mid - 1; else first = mid + 1; if (found) return mid; else return -1; The inputs for the functions are myArray[12] = {0,2,3,6,8,9,11,13,15,18,20,22 }; element = 8; Assume that you do not have a C++ compiler and you need to know if the function works. Fill out the next table every value change in each comparison or vanable (0) 0 myArray (0 2 [2] 3 [3] 6 [4] [5] [6] 8 9 11 [7] 13 [8] [9 15 18 [10] [11] 20 22 Comparisons and Variables Changes first element element length first last mid myArray mid found return value

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!