Question: Exercise 4. If you were to replace the midpoint computation by int mid (lo hi)/2; then which part of the contract will alert you to
Exercise 4. If you were to replace the midpoint computation by int mid (lo hi)/2; then which part of the contract will alert you to a flaw in your thinking? Why? Give an example showing how the contracts can fail in that case Exercise 5. In lecture, we used design-by-invariant to construct the loop body implementation from the loop invariant that we have identified before. We could also have maintained the loop invariant by replacing the whole loop body just with /loop invariant elided lo lo; hi-hi; Prove the loop invariants for this loop body. What is wrong with this choice? Which part of our proofs fail, thereby indicating why this loop body would not implement binary search correctly
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
