Saturday, 1 February 2014

Week 4: More Recursion

                This week we went back to recursion and got a more in-depth look at recursion. A function that is recursive must call itself at some point within itself. A recursive function needs a well-defined stopping state so it will not run away and cause an error in python. Recursion was new to me and I had trouble understanding it at first. I slowly started getting more comfortable with it after we traced it on the tree burst example in lecture. Recursion is useful for problems that require the function to be used twice or more. I enjoyed when Danny brought his “turtle” to class to give us a visual example of the turtle class in action. The only thing we did this week was recursion, it challenged and frustrated me at the same time. I felt that if I did not learn it, I would fall behind in class. Luckily I started understanding it more by the second lecture of the week. Learning recursion was one of my achievements for this week.

                Overall, my confidence with the material that was done this week I am fairly confident with it. I will reread the lecture slides and trace the recursive functions in my own time at my own pace to gain a better understanding of recursive functions. I’m glad that I can finally find some time to learn about recursion, I’ve been trying to find some time in the past for it but never found any time for it due to my workload. Exercise two was due this week. I started it a bit late but was able to complete it within a fair amount of time. I only had problems with part a on the exercise, part b went flawlessly. The first problem in part a occurred when I forgot to reassigned x after I tried to convert it into an integer. The second error was a silly one… I just forgot to raise the error… quite embarrassing.


                The tutorial this week was enjoyable just like the last one. The teaching assistant is very friendly, knowledgeable and helpful. The tutorial helped me with more thorough testing of my functions by using the unittest class. It took a few minutes to get the hang of it since I usually just use doctest to test my functions. I used unittest only once in CSC108 but I forgot completely about it. The tutorial was a good refresher for more thorough testing of functions. We also got to play around more with inheritance which was not hard to comprehend because of my previous experience with it. The only question lingering in my head if when a loop would be better to use rather than a recursive function.  

No comments:

Post a Comment