Answered step by step
Verified Expert Solution
Question
1 Approved Answer
2. Given a search function in Program 2. Answer all the following questions based on INPUT array shown in Figure B2. 1/Program 2 int search
2. Given a search function in Program 2. Answer all the following questions based on INPUT array shown in Figure B2. 1/Program 2 int search ( int search key, int array size, const int INPUT() ) { bool found = false; int index = -1 //-1 means record not found int MIDDLE, LEFT = 0, RIGHT = arraysize-1; while ((LEFT search key) RIGHT = MIDDLE - 1; // search is focused on the left // side of list else LEFT = MIDDLE + 1; // search is focused on the right // side of the list } //end while return index; }//end function 0] 5 [1] 9 [2] 19 [3] 25 [4] 34 [5] 40 [6] 45 [7] 49 [8] 66 [9] 75 [10] 88 [11] 100 Trace the value of LEFT, RIGHT, MIDDLE, INPUT(MIDDLE) and found (as in Table B1) for binary search operation performed onto INPUT array with the key numbers being search as following: 1. Search Key=40 2. Search Key=100 3. Search Key=8 Table B1 LEFT RIGHT MIDDLE INPUT(MIDDLE) found
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started