I had previously learned some recursion in my grade 12 computer science class but never really seemed to understand it too well. When we started learning it in CSC148, I was worried at first that i wouldn't be able to grasp the concept and apply it to programs. However with the exercises we've done in class and the labs I quickly began to understand how to implement it. I definitely feel once you wrap your head around whats going on and how it works, it becomes a lot easier.
The examples with the binary tree showed how useful recursion was. There were many applications for recursion such as finding the shortest path to a certain node, finding if a certain node is in the tree, etc. These tasks would of been unnecessarily lengthy (code wise) to accomplish just by iterating over the tree with a for loop or while loop.
What really helped me understand recursion was the exercises in which your write down your base case, then try to solve a smaller recursive case of the problem and finally implement your full code. By following this step by step process, I can see what I need and ultimately makes writing the full code a lot easier. Just like most problems, it's very difficult to tackle all at once and by breaking it down to simpler problems it becomes much easier.
The tutorials were extremely helpful as well. And really solidify the concepts for me. Although I did have some troubles at first, I managed to pick up the pace and finish the lab. I'm looking forward to using recursion in the next assignment because I see how much of a concept it is. I expect this assignment to take me a bit longer to work on then the first, so I'm planning on starting earlier (in terms of days to due date) then I did for the first assignment.
No comments:
Post a Comment