Friday, 6 February 2015

Tracing Recursion (Week 5 SLOG)

When first introduced to recursion, I found the concept very interesting. It sounded almost contradictory, in fact, that one could call a function containing the very same function in its body. I can imagine many cases where recursive code could look very simply, but tracing it would require a lot of brainpower. While the code we were required to trace in lab and on the midterm were fairly simple, I occasionally found myself making small mistakes such as forgetting to add 1 somewhere. It is helpful to note down which types of examples one has already traced, so that one can plug in its formula for an output in a more complicated recursion example. I guess the beauty in recursion is that it looks simple, but can tackle a multitude of problems that would have given us great trouble otherwise.

No comments:

Post a Comment