Friday, 7 February 2014

Week 4

This week in CSC148, we started with binary numbers and the binary case. We implemented code to calculate the binary representation of any number. This was possible primarily because of the fact that given n -1 binary numbers, we can calculate the nth binary number. For this type of code we learned how to formulate a recursive function. The recursive function acts like a helper function in itself in a way. It is useful when there is a complex problem to solve, as the recursive function draws upon previous return values and uses them like a helper function. Some important strategies we learnt were to firstly solve the base case and then generate all smaller permutations.            
For the base case, we resorted to using smaller numbers in the same function to visualize how the function would work for a simpler case.  This is similar to the method of Induction learned previously in an Introduction to Mathematical Proofs course, where we first solve the base case and then progress into solving for any n+ 1 value. In addition, the base case prevents the program from crashing, as it provides insight as to how the program would function on a larger scale. All in all, I must say that Recursion week has been quite the learning experience. This is definitely material that I need to review and practise a lot more, and hopefully, soon enough, I’ll be writing my own recursive functions.

No comments:

Post a Comment