Sunday, April 5th, 2015
In this post, I will quickly revisit a post that I made earlier in the year. Specifically, I will revisit my post about recursion (posted on March 3rd, 2015).
I have had a lot of experience with recursion since it was first introduced to us in the course, whether it be with term test 2, the assignments, or the lab exercises. One of the most common uses of recursion is for tree traversals. When traversing through a tree, you can use recursion to keep visiting each node, whether it be inorder(left, value, right), preorder(value, left, right), or postorder(left, right, node). This can be done until you find the node(s) you are looking for, and can perform some sort of function on them. I find recursion to be particularly useful in this scenario since it would be incredibly awkward to traverse the tree using another method such as a for/while loop.
I still struggle with using recursion since the functions we have to implement are becoming a little trickier to determine what the base case is. I particularly found it tricky to use recursion in the minimax algorithm for assignment 2.
I remember when recursion was first introduced in the course and we spent a week or two just tracing functions. It is pretty cool to see how my understanding of this concept has developed as the course has gone on.
No comments:
Post a Comment