Loop Invariants

Posted by Beetle B. on Tue 29 July 2014

A loop invariant is a statement that holds true just before and after each iteration. It may be violated within the iteration, but the invariant must be restored by the end of the iteration.

It is useful in proving correctness of algorithms that utilize loops.

tags : algorithms