What is loop invariant?
A loop invariant is a property that remains true at specific points during the execution of a loop. It is used to prove the correctness of algorithms by ensuring that the invariant is true before, during, and after the loop's execution. By establishing and maintaining a loop invariant, one can demonstrate that the loop achieves its intended result and contributes to the overall correctness of the algorithm.