Specify the Body
Rule of Thumb.
- Use the characterization to specify what the loop body must accomplish.
/* Given A[0..N] sorted in non-decreasing order, return the subscript of an occurrence of val in A (if val occurs in A) or N+1 otherwise. */
int find(int[] A, int N, int val)
/* Make L==R s.t. if val is in A[0..N], then
/* Reduce the size of the interval A[L..R]
approximately in half, preserving the
property that if val was in the
original interval, then it is in the
return ___________________________;