Change Algorithm 3 so that the binary search procedure compares x to am at each stage of the algorithm, with the algorithm terminating if x = am. What advantage does this version of the algorithm have?

SOLUTION

Step 1

In this problem, we are asked to alter the given algorithm so that the binary search procedure compares x to am at each stage of the algorithm,with the algorithm terminating if x=am .