In week 8 of CSC148 we continued on with recursion. This time we explored Trees in more detail and also worked on Binary Trees. We we given a pretty long list of functions to implement for Trees, which turned out to be good practice for recursion. The first couple solutions were all pretty straight forward and it became easy to move into the following functions somewhat mindlessly, assuming the same "simplest case" would continue for the other functions and that the recursive code would all be similar. It was a good wake up call and reminder that you can't really go on autopilot while doing this stuff. Recursion is difficult and really takes a lot of playing around with, I'm finding, to get comfortable with how it works.
Binary Trees, at least, seem much easier to work with than regular Trees. This is probably because their property of having arity less than or equal to 2 makes their structure more predictable. We are also shown some nice examples of Binary Search Trees near the end of the week - Binary Trees whose values are all comparable and whose values run from smallest to largest as you move from the left-most node to the right-most node of the Tree. You can search for values in this kind of Tree very effectively. The way we searched for values in the BST, by judging whether each node was less than or greater than or equal to the value we were searching for, really reminded me of using binary search on sorted lists.
The second term test is next week and I'll have to get studying soon. The two main topics on the test are LinkedLists and recursion, both of which are the hardest things we've learned thus far.
No comments:
Post a Comment