Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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