Loop Invariant
Rule of Thumb.
- Characterize the state after an arbitrary number of iterations, either in English of in a diagram.
- Introduce a variable to record the subscript of each boundary expected to change independently during the iteration.
If val occurs in A[0..N], then val occurs in the