Answer
To make the appropriate change, we add the following statement anywhere within the while loop:
if $x=a_m$ then return $m$
No other changes are needed to Algorithm $3$.
Work Step by Step
This was referred to in a previous answer dealing with binary search. Here, we are checking at each level if our value is equal to the mid-value. It is a slight change but it helps make the algorithm more efficient. For example, in exercise 13, we found the target value yet the algorithm did not terminate and continued iterating.
While the few extra steps saved for every iteration of the algorithm may not seem much, when there are millions and millions of search operations happening, that would equal a lot of steps in total!