Sunday, 2 February 2014
Week 4 - Recursion
So this week was all about recursion and understand how to both code and analyze recursive functions. The idea behind a recursive functions is easy however analyzing recursive function can easily get complicated; often requiring multiple iterations where its easy to make mistakes.I have done this before in high school so the concept of recursive functions is not new to me however, I know that these functions can get really complicated and often back-tracing can be hard. The way I imagine recursive functions is a series of nested while loops. Where the code constantly calls its self repeatedly to get a desired number or value of some sort. As you get your value, you feed it back up the x number of loops or iterations of your code to get your final answer. This code can be used for things such as permutations, where writing a code that runs a finite time can be tedious and or impossible. One of the examples I've learned from high-school is the Sierpinski's Triangle where you draw x numbers of triangles within a larger triangle with y number of dots. As one can see, a writing a finite code can get complicated whereas a recursion code simplifies it. Anyhow, as of this point of the course, I don't think I'm lost or learning something completely new as of yet although practicing back tracing as well as writing code can be helpful in avoiding errors.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment