Iterative Refinement
Rule of Thumb. If you smell an iteration, write it down.
- Decide between definite iteration and indefinite iteration
- Write down an appropriate pattern for the iteration.
- Do not fill in the pattern yet.
/* Sort A[0..m] into non-decreasing order. */
public void sort(int[] A, int m)
for ( ________; __________; _________)