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
The inductive hypothesis assumes that the algorithm is
Group of answer choices
correct for problem sizes and n
correct for elements
correct for any problem size n
incorrect if x Amid
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
