Initialization and Termination
Rule of Thumb.
- Use the characterization to refine the initialization, termination condition, and increment of the loop.
/* 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)
while ( _______________________)
return ___________________________;