Sunday 8 February 2015

Week 5: Impressions of Tracing Recursion

As discussed in my earlier post, I didn't really have much of a first impression on recursion because I had already been introduced to this topic in high school. However,  I will discuss my thoughts about the way we learned recursion in class and how it further developed my understanding about recursion. To start off, we were introduced to the idea of recursion through small steps because it can be a rather confusing topic to explain. We first learnt about tracing through simple exercises which asked us to identify the output we would get given a certain argument for a recursive function. In my opinion, tracing was not too tricky until we reached the point where there were several nested lists. I remember having to literally write out each step on paper to actually be able to visualize the steps.

The next part was then to actually understand what was going on with the function itself. For instance, in lab 4, we were given a mystery function with no docstring and we had to fill out the function description, examples and return type ourselves. For me, this part took a little longer than tracing because I had to analyze every line and think about various situations where there could be an error. Moreover, since the beginning in CSC108, I have had trouble figuring out which examples to use for my examples in my docstrings and unittests. No matter how many times I read through the slide about what to look for when writing examples, I somehow still seem to struggle with that part. Hopefully by the end of CSC148, I can overcome this challenge and be master at choosing test cases / examples for docstrings.

The last step in fully understanding recursion was none other than having to write code in recursion ourself. Based on the recursive functions I have written by myself so far,  I would say that it hasn't been too hard. Unlike high school, the explanation of what to expect in our recursive function was very clear and concise. If you just follow the explanation, its very easy to figure out the base case and the recursive case. Hopefully, it stays this way in the future or else I will be spending hours trying to figure out how to write a recursive function like in high school.


No comments:

Post a Comment