As what I have expected, term test 2 tested something about the loop invariant. I spent a lot of time on it and didn't finish the proof of termination of the program although that maight only take about one line or two. For the loop invariant part, I didn't think I got that right either, where I put a lot of things - a lot more that what it should be.
However, I think I am kind of getting it now. From what I think, loop invariant should include at least the preconditions of the loop, like the nature of the variables in the loop; the condition of the loop (the part after while or if) for the loop to execute; and the postcondition of the loop written with the subscript i denoting the ith iteration of the loop, for that in the last iteration of the loop, it will just return what the postcondition says. I hope this would work.
Anyways, I didn't do as well in term test 2 as in test 1. I should really investigate more on the loop invariant stuff for that there for sure would be a question on it on the final exam!
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment