Boy,
was I worried about recursion! My second-year friends and guys who I know took
this course last semester built up quite the hype for me. The way I understand
recursive functions is that it is a repeated application of a function within
that same particular function. What I initially thought was why not just use
for and while loops in the function when executing repeating operations. Well,
I do know from learning about running time and efficiency in CSC165 that loops
have n^2 running time, hence are not the most efficient way to go. My
conjecture is that recursive functions are used because they are more efficient
since I believe they are only n running time.
Week
4 mainly just consisted of becoming introduced to the idea of recursion and
being familiar with tracing them. It was not unlike the back in 108 when we
were asked to determine the output of a function except obviously the
difficulty did escalate with examples in this course. The functions primarily
dealt with determining sums of the elements in the lists and the depth of some
nested lists. The level of difficulty for me depended on what the functions
were asking me to do. The functions determining sums of the elements were
straight forward but for some reason and I can’t quite put a finger on it, but
determining the depth of nested lists felt awkward. However, all in all, I felt
that as long I read the code carefully both at first and every time I used the
function, I could produce results that were accurate to the specifications of
the functions. The instructor took it slow with the first tracing example, holding
our hands through each operation in the function. That instilled in me the need
to take things slow and be vigilant with each step. However, I realized last
week in the lab that taking extremes with that will result in unnecessary
tedium. The challenge for me now is to find that balance between being too
tedious and being careless and rash when tracing recursion.
If
anything is the calm before the storm, this is it. Although tracing was not
difficult, I am sure building recursive functions will be. I tried it by myself
with the lab exercise and I struggled with it. Hopefully in the coming weeks
the instructor shows us the methods and even some tricks to master creating
recursive functions. I can’t wait!
No comments:
Post a Comment