Question: This is a function which does a binary search, as we studied in class. We proved its correctness using induction. Answer the following regarding this
This is a function which does a binary search, as we studied in class. We proved its correctness using induction. Answer the following regarding this function.
You may have additional questions on this exact code later in the exam.
pre: A is an array ab of integers; a b
function BinSearch A:Array, ab: integer, x:eltype
if a b then
return false
else
mid :ab div
if x Amid then
return true
else
if x Amid
return BinSearchA a mid x
else
return BinSearchA mid b x
There are base cases in this function and
Group of answer choices
x is left of the pivot x i right of the pivot
array has elements array has elements
array has elements middle element matches x
array has element array has n elements
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
