In the lecture of week 4, we learned the concept of recursion, and how to trace a
recursion function. In computer science, recursion is the method of using a
function in the definition of the function itself. It is different from typical
thinking pattern of human beings. For example, to count non-list elements of a
list containing sub-lists, computers would have to work from a list to its
sub-lists to sub-lists of sub-lists and so on, while human would count whenever
we see a non-list element, no matter which layer of sub-list this element is
in.
Tracing recursion functions helps us to understand how they
behave. Professor Heap demonstrated how to trace a recursion function line by line. We should try to think as
computers when tracing recursion functions, from one step to the next, even
though we have the ability of jumping to the conclusion. At first, I was not used to it, and I had to force myself to follow the lines. However, after practicing, I figured out the
trick. Instead of looking at the whole jigsaw at once, I should start with the first piece of puzzle and move forward, following orders from recursion functions. With
this idea in mind, the whole process was no longer confusing.
After I mastered the skill of tracing recursion
functions, the logic behind these functions became clearer. In lab #3, we were
asked to write a single function using recursion, and it didn’t take me much
time. I am looking forward to writing more recursion functions.

No comments:
Post a Comment