Question: mplementation by Binary Search ( 1 8 p , Question 1 0 1 5 ) We shall implement the previous specification by means of an
mplementation by Binary Search p Question We shall implement
the previous specification by means of an algorithm FindB that maintains a search interval
Blohi such that
if v belongs to Bn then v belongs to Blohi
and which narrows down that search interval by cutting in half; if say lo and hi
then q becomes until a suitable p has been found:
FindBv Bn
lo hi n
found false
while lo hi and not found
q lo hi div
if Bq v
found true
else if Bq v
lo L
else
hi H
if found
return q
else
return R
where you must provide suitables choices for
pL
pH
pR
For the resulting algorithm,
p estimate as a function of n its worstcase running time
and simulate it by indicating how lo hi q and found change over time on the given example
p with v
p with v
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
