Saturday, November 1, 2008

Got hit on the head

For the grasshopper question... I wrote a proof of the recursive formula using combinatorics, and this lemma:

(n C r) = (n-1 C r) + (n-1 C r-1)

(n-1 C r) + (n-1 C r-1) = (n-1)!/r!(n-1-r)! + (n-1)!/(r-1)!(n-1-r+1)!

= (n-1)!/r! * 1/(n-r-1)! + (n-1)!/(n-r)! * 1/(r-1)!

= (n-1)!/r! * (n-r)/(n-r)! + (n-1)!/(n-r)! * r/r!

= (n-1)!(n-r+r)/r!(n-r)!

= (n-1)!n/r!(n-r)!

= n!/r!(n-r)!

= (n C r)

The proof I wrote was quite satisfactory. Then I got a very bright csc236 student to look at my code. He just hit me on the head with what he said: " How many ways can you jump to G(n)? only 2 ways".

ARRGH! Oh well it was good practice..

====
The material about proving preconditions => post conditions seems to be somewhat like a rigorous expression of what goes on in our heads when we write recursion or loops.

Although I definitely have trouble seeing the loop invariant component in proving the correctness of iterative methods. That part is not very intuitive for me. I'm having trouble finding the loop invariants that would assist in the proof. And, for that matter, don't know what I'm looking for either. Got some good tips at lecture how how to find them though.

Will have to go through lec notes and course notes extensively before the test. Gosh, what a busy week it's been, and what a busy week next week will be. For that matter, what busy months oct and nov are...

No comments: