Loop Invariant, cont.
Rule of Thumb.
- Use the characterization to specify what the loop body must accomplish.
- Use the characterization to refine the initialization, termination condition, and increment of the loop.
-
/* Sort A[0..m] into non-decreasing order. */
public void sort(int[] A, int m)
for ( int k = ______; k < _____; k++ )
/* Given that A[0..k-1] is finished,