Shortcut for chapter specific information

Showing posts with label loop invariant. Show all posts
Showing posts with label loop invariant. Show all posts

Saturday, May 21, 2011

Loop Invariant.

The Wikipedia entry is very detailed.  http://en.wikipedia.org/wiki/Loop_invariant .  Though I would consider the example program itself is slightly wrong.  (What if x was assigned to say 12?)

Wednesday, April 6, 2011

Loop Invariant

I start to learn what a loop invariant is and I wish I learned it long time ago.   It is a good habit to always think like this so that one can *prove* one is doing the right thing.

Intuition can help but it will fail when situation is complicated.  Besides, a loop invariant type of thinking can simply the loop and make it short.  (I like short program a lot.)