Sunday, 29 March 2015
Review an Old SLOG (Week 11 SLOG)
Ah recursion, we meet again. I seem to enjoy writing about this topic, so I shall do so again for this week's entry. Looking back at what seems like an eternity (but truly only 5 weeks!), I can see that I have gained a deeper understanding of recursion. Although the very basic examples of recursive code can be written in a few lines, they do not fully represent the ability of this powerful idea. When I first started tracing recursive code, I never thought that it could be used to represent a type of artificial intelligence. In the assignments, I was surprised that a relatively strong A.I. could be made using recursion. However, the run time proved to be an issue in some code where a large amount of permutations was possible. In our final assignment, we were given an option to explore various ways of improving the efficiency of our recursive minimax code. I agree with myself in the past where I believed that recursion would be a strong tool. Although thinking about it can make my head hurt sometimes, trusting the code seems to help untangle the mess that tracing can sometimes cause. Looking at other classmates' SLOGS, they seem to have issues with tracing as well. The problem with losing track of where you are in your code is a prevalent issue among our class.
Saturday, 21 March 2015
Impressions on Modifying BSTrees (Week 10 SLOG)
Last week we revisited an idea that we had just touched upon: binary search trees. As I had wrote about before, these trees are unique in that each internal node has a maximum arity of two, the data in the nodes are comparable, and the data in the left node is always less than the data in the parent node, while the data in the right node is always greater than the data in the parent node. This specific structure must be conserved when we add or delete nodes from the tree. On the one hand, because humans can view the entire tree in a single instance, we can easily make decisions on which node should go where when modifications occur. Computers, on the other hand, follow a more linear path and can only look at one node at a time, therefore an algorithm must be made for different situations. For example, the algorithm for deleting a node has 5 different scenarios that must be accounted for. I agree with Heap that a good way to go about writing these solutions is to write out what you want your code to do in plain English first. Write comments as often as you can to explain what your code is doing, so that in the future others can understand your code as well. Ultimately, whatever you write in English can be expressed in code.
Saturday, 14 March 2015
Impressions on Linked Data Types (Week 9 SLOG)
Unfortunately, due to the T.A. strike, we had no labs this week, so I had less help than normal with understanding linked lists. However, I still had the chance to go over the lab handout and work on the problems a bit by myself. The idea of a "wrapper" was new and caused some trouble initially. It seemed normal to make a separate class to hold all the linked lists elements, but I found it odd that the wrapper only had variables that referenced the front and back of a linked list. This initially caused me confusion when doing certain tasks such as finding whether a linked list contains a specific object, as I would not know how to access those LLNodes between the front and the back nodes. To solve this problem, I would have to "walk the list," as Heap mentioned; that is, to make reference to the front node, and while a certain condition is satisfied, have that node reference the next one instead. We also worked with mutating a linked list structure, in which the order of actions is very important. In the append example, we were shown that we must change the last values nxt variable first, and then add a node as the back, otherwise we lose the old back node. These linked lists were new to me and I will most likely need to revisit them and tinker with the code once things get settled down over the next few weeks.
Thursday, 5 March 2015
Impressions of recursive data types (Week 8 SLOG)
Last week, we looked at a different type of tree called a binary tree, where each node only has two children. In some ways, the binary tree is simpler than a standard tree, as we can assign variables to the left child and right child, rather than finding a desired node through indexing. Not only does this make writing recursive code slightly easier (in my opinion), but it is also less mind-twisting to think about (again, in my opinion). Additionally, we looked at a type of binary tree called a binary search tree, where the left child node is always less than the current node, and the right child node is always greater than the current node. This makes searching for a particular node much more efficient, as you can effectively reduce your search time in half with the first iteration. In lab 6, we looked at implementing functions using a binary tree. Some of these functions proved to be more challenging as the conditions for desired results were usually more numerous than past exercises. Careful implementation and meticulous testing seem to be vital in order to write functions for these trees, binary search trees in particular.
Subscribe to:
Posts (Atom)