I can't generally map Loop Invariant method for proving the correctness of an Algorithm. Take the case of an Insertion Sort(adsbygoogle = window.adsbygoogle || []).push({});

http://csnx.groups.allonline.in/pool/Introduction%20to%20Algorithms-Cormen%20Solution.pdf

in the above link, at the page 2-3, they have proved the correctness of insertion sort using loop invariant. As of I understood, a loop invariant is a condition that will exist in an Algorithm(not necessarily), which always holds true, irrespective of the state of the Algorithm. And how is this used in proving the correctness? Besides in the same book it has been mentioned:

"Note the similarity to mathematical induction where to prove the property holds, you prove a base case and inductive step. Here, showing that the invariant holds before the first iteration corresponds to the base case and showing that the invariant holds from iteration to iteration corresponds to the inductive step."

Here, I can understand the lines above, but still not convinced with the explanation. Can anyone help me out...??

**Physics Forums - The Fusion of Science and Community**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Loop Invariant in Analysis of Algorithm

Loading...

Similar Threads for Loop Invariant Analysis | Date |
---|---|

Why does entering '0' terminate do-while loop here? | Feb 2, 2018 |

Continuous-time loop computer for NP problems? | Oct 30, 2017 |

C/++/# Why can I print C-Strings without a Loop? | Apr 11, 2017 |

C/++/# If-else statements in for loops | Apr 10, 2017 |

What is the loop invariant for this algorithm? | Mar 18, 2012 |

**Physics Forums - The Fusion of Science and Community**