As mentioned in week 8's post, binary search trees can sometimes be problematic. The example that I remembering being the most convoluted was deleting nodes from a binary search tree. There were like 6 different cases that we had to account for and write separate if statements. That was pretty crazy. I imagine that when I try to write that code, I'll get some serious errors, and I'll have to test each case individually to know what's really broken.
The test! Went alright. The structure was pretty much identical to the 2014 previous midterm. The only thing that I forgot to review was the post-order traversal for the tree. I think I got it right. I forgot the order of left tree, right tree, node, but the name "post" kind of gives away the fact that the node will be the last one checked. Also, I think I got lucky on the tree function question called leavesbetween I think. You gave it a range for a tree and it gave you back all the values within that range that were also leaves. On my cheat sheet, I had written down a function from one of the labs that returned values for internal nodes I think. So instead of checking if it had no children, I just had to check if it had at least one child. So that was pretty fortunate =).
No comments:
Post a Comment