Wednesday, 9 October 2013
Recursion
I've already talked a lot about recursion in my previous posts, mostly because it has caused me so much suffering over the past few days. However by the end of assignment A1 (the very end, see my first post as to how close I cut it), I got it. Recursion is only as useful insofar as you understand it. You have to be very careful to pass information up and down the trees; if you mess up, errors can be very difficult to rectify. In simple terms, recursion is when a function calls itself- however as by calling itself, it calls itself again, you can very easily create an infinite recursion loop. Luckily there is a maximum recursion depth to prevent the system from completely crashing. However, if you can successfully impose conditions to end the function, then you can use it to drastically reduce the number of lines of code you have.
Subscribe to:
Post Comments (Atom)
Is it computationally efficient to use recursive programming?
ReplyDelete