Question: Given the following code for binary search, binarySearch () and the content of the list below, fill Table 1 below with the values of

Given the following code for binary search, binarySearch () and the content 

Given the following code for binary search, binarySearch () and the content of the list below, fill Table 1 below with the values of first, last, mid and list[mid] when calling the function binarySearch (81) ie. when searching for 81 in the list, until 81 is found in the list. int binarysearch (int item) { int first = 0; int last = length bool found - false; while (first item) last = mid - 1; else first = mid + 13; if (found) return mid; else return -1; 0 1 2 3 2 5 7 15 21 28 29 37 45 51 57 4 5 6 7 8 9 10 11 12 61 13 14 81 15 16 17 List= 72 78 87 91 97 Table 1 Iteration first last mid List[mid] 1 2 3 4 6

Step by Step Solution

3.38 Rating (164 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

binarySearch81 Iteration first last mid listmid Exp... View full answer

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 Algorithms Questions!