Saturday, March 19, 2016

Midterm 2 and Assignment 2 (Week 9)

The midterm was a lot easier than I expected. I really thought the professors were going to trick us by either telling us how to implement a certain type of tree traversal or extremely hard recursive functions, but the midterm was only testing us if we knew the general concepts and applications of linked lists and recursion. That made the test really fair. I had almost no trouble implementing linked lists and trees in the labs, so I was almost surprised when the functions we had to implement had extremely similar features to those in the labs. Unlike the first midterm, I had enough time to check my answers in the second midterm, but I can't be too sure of my grade in the second.
The question that interested me the most was when we had to modify a tree such that we had to swap its children. I've heard of using a dummy variable when you swap two variables with each other (since trying to assign one variable as the other one will overwrite the other one), so I decided to use that. Once I've taken care of that base case, the general case was pretty straightforward, which was doing the same thing for the left and right children (if the tree has any).
As for Assignment 2, implementing the two searches from the puzzle tools file seems extremely daunting; Luckily, it takes a lot of thinking and planning to actually carry these functions out. I'm going to break this down into smaller, more solvable tasks since that strategy actually worked the best for me when I try to implement the extensions for the grid peg and 15 puzzle. During the last lab, I've thought about how I would carry out both functions, but I haven't actually written them down yet, but it did involve using a variable that keeps track of what extensions have already been checked. Let's hope that when I run my functions, it doesn't run for too long. I've heard in a couple of Piazza posts that the grid peg solitaire or word ladder tends to run for at least a couple of hours...
Other than that, I have had no trouble implementing the binary tree functions, expect when deleting a node from a binary tree. I'll have to review that.

No comments:

Post a Comment