In one of my previous blog entries, I shared my first (and very brief) impressions about recursion. Today, I would like to talk more about this concept which so far has been the most important topic in the entire course.
When recursion was first introduced I did not realize to the full extent how significant it will be for this course. First, the idea of calling a function on itself seemed pretty odd to me, but with time and practice I came to a better understanding of how this process works. The exercises with the search trees helped to finally understand that recursion works by executing the main body of function if the stated condition is satisfied, and then coming back to the original state. It took me a lot of time to comprehend how the trees might be traversed with the help of recursion; however, writing functions for assignment 3 was very useful for getting the practice in creating the recursive calls.
Still, I am not completely comfortable with applying recursion to all the problems I need to solve. It becomes very difficult for me to use it properly, when the recursive call should be used to create the new data structures, such as lists or dictionaries, or when I need to somehow keep the track of the recursion traversing the tree. It is also pretty difficult for me to figure out in which case I should apply recursion. At this moment, I am pretty sure that it is appropriate to use it when nested lists or trees are involved. However, it is not always easy for me to determine at what point in the program I should use the recursive call. For some time in the past, I have thought that the recursion executes only the part of the function that is written before the call. When at some point I realized that the part following the recursive call is also executed, it was a big surprise, which changed a lot of things for me. Nonetheless, it is not easy at times for me to think recursively. When I look at the search tree, in my mind I can automatically count nodes, leaves, and determine the paths from the root to the nodes. It is difficult for me at times to overcome this automaticity and start thinking about recursion processes happening in my cognition. Anyway, I try my best to understand how each function or method I write should work, and where recursion should be used.
As for comparing myself to others, I think that http://dogthatslogsthroughthefog.blogspot.ca/ is a really interesting blog, and the author writes about the course-related concepts much better than I do, but probably has the same problems with recursion.
Concluding this post, it’s worth saying that my understanding of the concept of recursion has improved during the course. However, I really wish I could get more practice with it and be able to appropriately apply it to programming problems.
No comments:
Post a Comment