Question: C++ Program Instruction: the first line of the table first the second my array mid ==element 4 answer the third myArray mid> element 1 answer
C++ Program Instruction:
the first line of the table first
uuestion COmpletion Status: Consider the following function: Eint binarySearch(int myArray[], int length, int element) { 10 11 int first = 0; %3D int last = int mid; 12 length 1; 13 14 15 bool found = false; 16 while (first element) last = mid - 1; 22 23 24 else 25 first = mid + 1; 26 27 if (found) 28 return mid3; 29 else 30 return -1; 31 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 variable, [1] [2] [3] [0] myArray 0 [5] [6] 8. [7] [8] [9] [10] [11] 9. 11 13 15 18 20 22 ENG 1/220 a. Comparisons and Changes Variables first element element d0 ENG hp length first last mid myArray mid found return value 4 40 ENGthe second my array mid ==element 4 answer
the third myArray mid> element 1 answer
the four element 1 answer
the five length 1 answer
the six first 3 answer
the seven last 2 answer
the eight mid 4 answer
the nine my Array mid 4 answer
the ten found 5 answer
the eleven return value 5 answer
total answer 35




Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
