Saturday, March 28, 2015

Week #11: Revisiting my previous SLOG posts

I cannot believe that my CS first year is almost done at U of T. Studying CSC 148 developed me as a better software developer although the only language I know is Python. I am planning to study C by myself during summer vacation to prepare for my second year as CS undergraduate at U of T.

Looking at my posts, I am proud that at least I kept writing my SLOG posts weekly which shows my dedication and passion towards this course. I believe that writing SLOG post is very helpful as it allows me to review the course material. Not only that, reading others' SLOG posts enables me to view the course materials in different aspects. Writing about why computer scientists should write on my first post allowed me to reflect on the importance of writing even in subjects like computer science. Computer science is not all about code-writing. Computer science is essential in our daily lives. I am glad that I study computer science at U of T.

I also agree with my previous posts that using office hours wisely is one of the best learning methods. Instead of struggling over one question for 2-3 hours, asking a question to Professor Heap after some attempts saves my time and teaches me more than any other method. What I was confused about at first was recursion, so I visited Professor Heap to talk about it. With his help, I am now confident in my recursion skills. I also attempted another method. As shown on my week 7 post, when my partner and I had problems with lab 05, we attempted a new method where the first one writes code and the next one tries to debug it. That was also a success although it took us some time. I guess there are many ways of learning in computer science. I believe that these two methods suit me the most as these assisted me to learn CSC148 in depth.

Tracing recursion was the easiest as I was able to see the pattern clearly. I got perfect on that quiz. Interestingly, I've revisited my week 5 post when I was learning recursion more in depth during week 6-8 to re-enforce the basic concepts of recursion. Likewise, revisiting  my previous posts always helped me to review the course materials throughout the term.

Writing SLOG posts helped me reflect on the course materials and myself. Whenever I wrote my posts, I always tried my best to demonstrate my understanding so that I can revisit later during the final exam preparation period and other students might find my posts useful.

It was a challenge for me to actually find SLOG posts which was updated weekly. Most of the SLOG blog were inactive. I wonder why students gave up on writing SLOG posts weekly. Is it because they don't have time? I believe that writing SLOG post does not take too much time. Even writing just a bit is fine if one is so busy.

I am glad that TA strike is finally over. I would like to thank both TA and U of T as they have decided to settle the strike. The final exam period is also approaching. I hope that CSC 148 final exam is easy. It's time for me to study! You can do it, Julian!

I also found these SLOG blogs fascinating as the writers kept writing weekly just like me. Not only that, their explanation on the course materials was great. I also commented on how great works they have done. Here are the links below.
http://csc148sonny.blogspot.ca/
http://aquaticliving.blog.com/   <- I wasn't able to comment on it since the comment option was not
                                                  available, but I want to say "don't give up!" to the writer. I am sure                                                     that the writer can overcome the challenge he or she is facing currently.
http://csc148eunn.blogspot.ca/

Their postson CSC 148 course materials are very impressive. They have demonstrated their approaches to problems in depth and how they interpret problems differently. Not only that, their summaries are in detail and well-organized. I also agree with most of their posts and I want to say great work to those who constantly wrote his or her SLOG posts.

Friday, March 20, 2015

Week #10: My impressions of Week 9

We had only one lecture class for Week 9 since we had term 2 test on Wednesday. For the term test, I just hope that I achieved A on it. Professor Heap also clarified on which subjects are included for the test. Thanks to Professor Heap, I exactly knew what I had to study for. I would like to thank Professor Heap for his works.

During week 9, we focused on BST (Binary Search Tree) and its methods insert and delete. As the course material was fairly straight forward, I had no problem understanding the concept. Although I was confused by random module for Lab #8, my friend and I worked on it together. I also used Danny's office hours in order to understand the basic concept since I've realized that asking a question to professors is a much better than struggling over the question for 2 to 3 hours. One thing I noticed is that the course material for lab #8 will be revisited in different ways for CSC 263. This means that if I do not understand the problem and just ignore, this will once again come and cause problems to me later in CSC263 or other CS courses. Thankfully, with the help from Professor Heap, I understood the problem perfectly.

I would like to demonstrate some basic implementations for BST, insert and delete methods. For BST, we also need class BTNode. However, I will skip on the implementation part of BTNode as I've discussed before on my previous posts. The source is from lab 08 by Professor Danny Heap.

Now then, for class BST. 
(Source:  http://www.cdf.toronto.edu/~csc148h/winter/Labs/lab08/bst.py)

class BST:
"""Binary search tree.""" def __init__(self: 'BST', root: BTNode=None) -> None:
"""Create BST with BTNode root."""
self._root = root
def __repr__(self: 'BST') -> str:
"""Represent this binary search tree."""
return 'BST({})'.format(repr(self._root))
def find(self: 'BST', data: object) -> BTNode:
"""Return node containing data, otherwise return None."""
return _find(self._root, data)

(Source:  http://www.cdf.toronto.edu/~csc148h/winter/Labs/lab08/bst.py)




What I want to demonstrate now is insert and delete methods.
(Source:  http://www.cdf.toronto.edu/~csc148h/winter/Labs/lab08/bst.py)
def _insert(node: BTNode, data: object) -> BTNode: """Insert data in BST rooted at node, if necessary, and return root.""" return_node = node if not node: return_node = BTNode(data) elif data < node.data: node.left = _insert(node.left, data) elif data > node.data: node.right = _insert(node.right, data) else: # nothing to do pass return return_node
def _delete(node: BTNode, data: object) -> BTNode: """Delete, if exists, node with data and return resulting tree.""" return_node = node if not node: pass elif data < node.data: node.left = _delete(node.left, data) elif data > node.data: node.right = _delete(node.right, data) elif not node.left: return_node = node.right elif not node.right: return_node = node.left else: node.data = _find_max(node.left).data node.left = _delete(node.left, node.data) return return_node
(Source:  http://www.cdf.toronto.edu/~csc148h/winter/Labs/lab08/bst.py)

Professor Danny Heap kindly provided us with the implementation of BST methods insert and delete. Although I had trouble understanding these methods, I got used to it soon as I've already experienced various Binary Search Tree. I think my experience on previous lab exercises also helped me understand lab 8 materials. I believe that doing lab exercises help me study and understand the course materials and develop me as a better computer scientist. 

Saturday, March 14, 2015

Week #9: My impressions of week 8

During week 8, we learnt about linked list and LLNode. Learning linked list was difficult compared to other aspects of computer science.  What professor Danny emphasized on was to draw pictures for linked lists. At first, I was not used to drawing diagrams to represent linked lists. However, I practiced drawing diagrams to understand linked lists. Interestingly, the last question of the test actually asked for a diagram for linked lists.

LLNode was very easy to understand as it is a node for linked list. I would like to demonstrate implementations to initialize LLNode and LinkedList based on Danny's lectures. (Source: http://www.cdf.utoronto.ca/~csc148h/winter/Lectures/Danny/W8/node.py)

class LLNode:
    def __init__(self, value, nxt=None):
        """ (LLNode, object, LLNode) -> NoneType
     
        Initialize LLNode with value and nxt
        """
        self.value, self.nxt = value, nxt

class LinkedList:
    def __init__(self):
    """ (LinkedList) -> NoneType
 
    Initialize LinkedList self by making an empty linked list.
    """
    self.front, self.back = None, None
    self.size = 0
(Source: http://www.cdf.utoronto.ca/~csc148h/winter/Lectures/Danny/W8/node.py)

The most difficult part was to implement methods like __contains__ in order to find whether it contains a certain number or word. So I would like to go over __contains__ method on this post. The following implementation for __contains__ is from Danny's slides. I added comments to go over the implementation step by step. (Source: http://www.cdf.utoronto.ca/~csc148h/winter/Lectures/Danny/W8/node.py)

def __contains__(self, value):
    """ (LinkedList, object) -> bool
 
    Return True iff LinkedList self contains value.
 
    """
    cur_node = self.front    #Here we set a new variable called cur_node
    while cur_node:       #check whether cur_node exists
        if cur_node.value == value:     # if the first element of LinkedList contains value
            return True           # return True
        cur_node = cur_node.nxt      # if not, we move onto the next element of LinkedList
    return False       # there is no cur_node as it reached the end of LinkedList
(Source: http://www.cdf.utoronto.ca/~csc148h/winter/Lectures/Danny/W8/node.py)

Learning about LinkedList enabled me to understand computer science in depth. Although it's just a basic material for typical computer scientists, it is a huge achievement for a newcomer like me to learn and understand LinkedList concepts.

During this week, I spent three days studying for CSC 148 term 2 test. I first reviewed Danny and Diane's lecture slides and lab materials. Then, I tried solving five past exams. What I always had the challenge the most was LinkedList part. In order to overcome this challenge, I tried implementing new methods for class LinkedList. Not only that, I always tried to solve the past exam within 50 minutes. The term test was not that hard, but the last question was quite confusing to me. Sadly, the last question was about LinkedList. Although I am not 100% sure about my answer for the last question, I tried my best, so I have no regret. I hope to achieve A on this term test.

I also visited other students' SLOGs in order to learn how other students approach CSC148 and its course materials. Unfortunately, some of the SLOGs were inactive. The following links are the SLOG posts which I found interesting and left some comments.

http://148wuboyangw3.blogspot.ca/

http://computersciencemaggie.blogspot.ca/2015/03/summary-of-object-oriented-programming.html?showComment=1426384453547

http://csc148slog1001429162.blogspot.ca/2015/03/linked-lists.html#comment-form





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.