Hi,
I've been reading an algorithm book and after learning and understanding the insertion loop the topic of loop invariants comes up which confuses me somewhat. They appear, to me, to be just statements that the loop will work, i.e. the loop invariant remains true at the beginning of each iteration of the loop and when it terminates. This seems non-sensical to me as that is the entire reason for creating the algorithm in the first place so why do we need to state it?
I'm more practical than theoretical which I believe is halting my ability to understand the theory behind it. Can someone explain the use of loop invariants please? Do they help to create algorithms or are they just to prove correctness, in which case what is the process of proving an algorithm before creating it using loop invariants?
Thanks.
BebopSong