Question: function bsearch( A,first,last,key ) if first > last then return -1; end if mid = b( first + last ) / 2c; if key ==
function bsearch(A,first,last,key) if first > last then return -1; end if mid = b(first + last)/2c; if key == A[mid]) then return mid; end if if key < A[mid] then return bsearch(A,first,mid,key) else return bsearch(A,mid + 1,last,key) end if
end function
i. no, counterexample of input: A = [1,3,6,7,12,15,32,47], first = 1, last = 8, key = 32 ii. yes
iii. no, counterexample of input: A = [1,3,6,7,12,15,32,47], first = 1, last = 8, key = 22 iv. no, counterexample of input: A = [5], first = 1, last = 1, key = 3 v. no, counterexample of input: A = [5], first = 1, last = 1, key = 5
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
