Saturday, 1 March 2014

Week 7: Recursion

Through the last  few weeks the main topic of study was recursion. The literal definition of recursion is "defining something in terms of itself", possibly multiple times to achieve your objective. In code this would mean that a function would call itself again and again until some condition is met (the final goal/solution). A real life example of recursion is when someone could say "everyone has a Mother". You can constantly say that about one person and the person who is the Mother. So in programming terms a recursive function must constantly go deeper and deeper in to itself.

Going in to the topic of recursion I was not comfortable with the idea of it. But after listening to lectures and doing my own research I able to grasp the basics of how it worked and what it was used for. Recursion is used to solve problems that are depended on smaller instances of the same problem. This is like dividing a problem into a sub problem of itself. Even though I understood the main idea of recursion, when it came to tracing solutions for examples during class and tests I was confused. I was able to overcome this problem when I learned how to divide each instance of a recursive function separately based on a parameter and thus be able to trace the values output by the function.

I am able to see the possibility of using recursion in programming. After using it in the Tower of Anne Hoy I was amazed with the possibility and applications of recursion. How it was able to solve a problem without a DEFINITE solution, by this I mean how the solution to how many cheeses' there were in the problem the recursive function was able to solve the problem for how to complete the game. I am excited on future possibilities and programs that would possibly become more complicated and will be able to do more with recursion.