Sunday, 29 March 2015

Week 11: Looking back at previous SLOGs

As I approach the end of the semester, everything in the course is starting to fall together. In week 6 and 7 I was being introduced to recursion on trees, and at the time I would play with the implementation until my code was correct. I wouldn't fully understand why the recursion worked, I would just trust that the function would take care of all the underlining work. However, with more practice on implementing trees in my labs after week 7 and my assignments, I began to thoroughly trace each function in parts first before I put them in list comprehensions. This tracing helped me have a better grasp on what the function is trying to do and which traversal it uses when visiting each root. This week especially has helped me understand recursion as more than calling the function as a list comprehension, as what I tried to emulate when I talked about recursion in my "Week 7 Impressions" blog. By discussing with friends some hints to some of the functions' recursion algorithms for assignment 3, I used helper functions that would trace the main function step by step, which was then added to a set. A3 gave me more experience in writing recursion as separate steps, compared to my class or lab list comprehension examples. While list comprehensions are useful and efficient, it becomes difficult to trace and write on the spot (in my case as a computer science beginner). So from now on, instead of jumping straight to list comprehensions, I will write my code in parts first so that I can understand the recursion, and then try to right the code in a list comprehension if the implementation is easy enough. And when I get comfortable enough with recursion, then I will implement with a list comprehension on the first try.

Sunday, 15 March 2015

Week 7 Impressions

In week 6, we were introduced to the terminology for recursive trees and how to implement these types of functions. Now for week 7, we extended our knowledge of recursive trees and introduced Binary Tree Nodes (BTNodes) and Binary Search Trees (BSTs). This allows you to search for a value more effectively in a logarithmic function. In our labs we also implemented BTNode methods. This lab was the first lab that I began to write 'if' and 'else' statements in one line to make them look like list comprehensions so that the code looks cleaner. I also wanted to allow myself to have more options when writing my code. By having data to represent the left side of the node, the right side of the node and the node itself, I learned that there are three ways we can recursively explore a BST (which are inorder, preorder, and postorder). By learning these three tree traversals, I am now able to examine how a tree is evaluated when it is placed in binary order. I hope to use this recursion material in later weeks and later assignments.