Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Program This only one Question Consider the following function: 6. Bint binarySearch(int myArray[], int length, int element) { 10 11 int first = 0;

C++ Program This only one Question image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Consider the following function: 6. Bint binarySearch(int myArray[], int length, int element) { 10 11 int first = 0; 12 int last = length 1; 13 int mid; 14 15 bool found = false; 16 17 while (first element) last = mid - 1; 22 23 24 else 25 first = mid + 1; 26 27 if (found) return mid; 28 29 else 30 return -1; 31 The innute for the functionsaro The inputs for the functions are: myArray[12] = { 0,2,3,6,8,9,11,13,15,18,20,22 }; element = 8; %3D 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. [0] [1] [2] [3] [4] [5] [6] | [7] | 11 [8] [9] 18 15 [10] [11] 20 22 myArray 9. 13 T16 PM 1/12/2020 a. de ENG delete home end prt sc v Question Completion Status: Comparisons and Changes Variables first element element length 11:17 PM ENG V12/20 home end prt sc delete * Question Completion Status: length first last mid myArray mid found return value FR17 PM a. 12/20 home Dg up end delete prt sc

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions