I am having some troubles stating the loop invariant, like the example we had during Wednesday's (Oct. 29th) lecture. For the function counter, how we worked out its loop invariant to be: a and b \in N, and 7*m + n = 7*a_i + b_i + c_i? I think I know why a and b has to be natural numbers, but for the latter part, the equation, I really didn't get it. Did we use the trail and error, or there is a systematic way for us to find the loop invariant for any while loops and for loops?
I know the casual defination for the loop invariant is that any variable or relationship that is unchanged during the loop's execution. However, will that just be the loop's content itself?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment