Wednesday, 5 February 2014
Recursion
Last week, we began learning about recursion and were able to implement this knowledge into this week's lab. We traced methods that used recursion such as one that converted numbers to their binary representation, but we also wrote recursive methods ourselves, such as ones that freezes lists. Through these exercises, I was able to better understand what recursion is and how it works. A recursive function is one which calls upon itself within the function. This is useful when trying to execute nested loops. However, one disadvantage of recursion as I am told is that it is much slower than non-recursive function, and can cause StackOverflow. Recursion seemed complex to me because it was difficult at first tracing the functions as it entered into nested loops, but because of the exercises we practiced with in our labs, I was able to better understand recursion.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment