Recursion is one of the hardest topic that I've learned so far. Functions that are using recursion are often very short, but the amount of complicated problems that they can solve is amazing. Sometimes recursion is really hard to understand by simply look at the code, that's why we have to trace recursion in order to understand it easier.
Most of the recursion examples we did in class are about nested list. I feel like tracing this kind of recursion is relatively simple because all it does is breaks down the nested list into smaller items until the item becomes a non-list object. We are also allowed to skip the process if we have traced a similar example before (if we traced a list with same depth), which reduced a lot of work load.
I find tracing recursion really useful because it deepens my understanding of what the computer does. I've learned recursion in high school before (without tracing), and I found it impossible to understand, and most of the times I just used trail-on-error to write my recursion code.
No comments:
Post a Comment