Saturday, March 7, 2015

Week #8: My impressions of Week 7

During last week, I spent lots of time on implementing function and methods for Assignment 2. My partner and I faced many challenges. Instead of struggling over the problems we faced, we met Professor Heap during his office hours for any hint. What we had the problem the most was minimax. At first time, I thought that I could implement that quickly with no problem. But that was wrong. My partner and I tried implementing minimax strategy for three days, but it did not work.  So we visited Professor Heap three times in order to understand what minimax strategy actually does. With the help of Professor Heap, we were able to understand the minimax materials. One thing I realized was to use office hours wisely. Professor Heap was always willing to help us whenever we visited him. I would like to thank Professor Heap for his hard work.

During the lectures in Week 7, Professor Heap explained briefly about Assignment 2. It seemed that many people had the same  problem as me. The lectures mostly focused on a binary tree. BTNode should have two children. So we initialized it like below.  (Source:  http://www.cdf.utoronto.ca/~csc148h/winter/Lectures/Danny/W7/monday-annotated.pdf)

class BTNode:
    def __init__(self, data, left=None, right=None):
    """ (BTNode, object, BTNode, BTNode) -> NoneType

       Create BTNode self with data and children left and right.
    """

    self.data, self.left, self.right = data, left, right
(Source:  http://www.cdf.utoronto.ca/~csc148h/winter/Lectures/Danny/W7/monday-annotated.pdf)

Initializing BTNode was easy as we learnt it during Lab 06 as well. However, writing an implementation to evaluate a binary expression tree was a challenge to me. In order to check all the leaves in the node, we had to use recursion.

I also learnt Tree traversal. There are 3 Tree traversal called in-order traversal, pre-order traversal and post-order traversal. I referred to Diane's week 7 lecture slides in order to understand what these three are. The definitions for these three terms are from Diane's slides.
(Source: http://www.cdf.utoronto.ca/~csc148h/winter/Lectures/Diane/w7/Trees-2.pdf)
In-order traversal checks a node in between checking its two children
Pre-order traversal checks a node before its children
Post-order traversal checks a node after its children
(Source: http://www.cdf.utoronto.ca/~csc148h/winter/Lectures/Diane/w7/Trees-2.pdf)

Week 7 was very easy compared to other weeks. I guess it's because week 7 is a combination of recursion and BTNode that I've already studied before. I believe that my CS skills are improving everyday as I practice implementing various functions and methods during my spare time. I hope TA strike will settle soon with good results for both the university and TAs.

1 comment:

  1. Thanks for summarizing the every concept Diane mentioned this week! :)

    ReplyDelete