Thursday, March 31, 2016

SLOG Week11

    As I mentioned early in Slog 7, I was struggling with recursion especially on the topic of tree. However, In the subsequent study, I found that recursion was way more easier to understand than what I thought before. Also, the usage of recursion seemed straightforward on both tests and labs. All we need to do is to combine base cases with recursive cases. Usually, the base case is simple to come up with and this is the reason why recursion would be considered as an easy part from my perspective. Therefore, my views on recursion have totally changed which motivate me to do better in this section.
    After test two, I felt surprised that linked list had become a big challenge to me. My grade on this part was below the average. I was a bit upset since I spent much  time studying on linked list before the test. Anyway, I would put more efforts on linked list and get prepared for the final.

Sunday, March 27, 2016

SLOG Week 10

    This week was relatively easy since school is off on Friday. Also, the tutorial this week was relaxing since we didn't need to write any codes. All codes were provided and all we need to do is to change some numbers and copy and paste different results into a table. The topic this week was focused on comparing efficiency among different sorting algorithms. It is easy to understand because some of methods are covered in last semester. We only have 2 weeks left and I should get prepared for the final earlier. Hopefully I could complete this course and receive a satisfying grade.

SLOG Week9

    Week 9 is a busy week since I had prepared for the test 2 on Wednesday and I need to start working on assignment 2 right away. Test 2 seems easier than previous one. Unlike test 1, I have much more time left when I complete it. The root reason is that we don't need to write API this time. On assignment 2, all we need to do is to solve different type of puzzles. I found interesting on sudoku puzzle. After completing the body and try to run it, the solving time differs in a wide range. Sometimes it only takes few seconds to solve a sudoku, but nearly one minute will be taken to solve the same sudoku puzzle when I run second time. Anyway, I expect to complete the assignment right after the weekend to avoid rushing on the due day.

Saturday, March 12, 2016

Slog Week8

    This week we were still working on trees, especially Binary trees that have two children, left and right. We focused on different orders to visit nodes through a tree. The professor introduced us three different orders to visit the tree and the one that I felt confused with is level order. The following is an example:

def visit_level(t, n, act):
      """
   Visit each node of BinaryTree t at level n and act on it.  Return
   the number of nodes visited visited.
   """
   if t is None:
       return 0
   elif n == 0:
       return 1
   else:
       return (visit_level(t.left, n-1, act) + 
               visit_level(t.right, n-1, act)

I'm struggling with the else part. I don't understand why it should be n-1 but not n instead. if n = 1, aren't we visit the tree at level 0? I guess the outcome would be 2 but not 3 as we expected. 
    Also, term test two is coming, and we have assignment two to due by two weeks. Hopefully I will be well prepared for the upcoming test and get started for the assignment. 

    

Thursday, March 3, 2016

SLOG Week 7

    This week, we continued working on recursion, a function calls itself one or more times in its body. Unlike last week, the concepts in this week are more complicated that we need to be more concentrated. When the professor introduced class Tree, I was struggling with the function leaf_count(t). I understood that node with no children is called a leaf, and the number of leaf would be one if there exists a root only in the Tree. However, I was wondering that if a root connected to an empty list, should we count that a leaf or not. Fortunately, the professor answered my question that the total number of leaf would remain one if the child is an empty list.
    The approach to write a recursive function body seems straightforward. The general form is divided into two parts. One is a base case without using recursion, and the other one is a general case that involves recursion. The following is an example: 

def leaf_count(t):
    """
    """
    if len(t.children) == 0:
           return 1
    else:
           return sum([leaf_count(c) for c in t.children])

Even though the step seems easy to understand, I still need more practice in order to get a good mark on the upcoming test.

Friday, February 26, 2016

Slog Week 6

    After reading week, we start on a new topic called recursion. Basically, it is a way to simplify a problem with large extent , in which a function calls itself one or more times in its body. Also, recursion has something to do with nested lists. The function depth(obj) is exactly a way to sum the total possible nested lists in object.
   The lab this week was quite interesting. Some new methods like zip or tuple unpacking were introduced. However, we need to use our old method to rewrite the given body of new methods instead. I think the point of the lab is to reinforce our ability on for loop and while loop. Though the new approaches seem easier to solve a problem, we should not forget our basic methods.

Monday, February 15, 2016

Slog Week 5

    The most important thing in this week is the term test written on Wed, I don't feel well about this test since I couldn't complete the test in a given time. I spent much time reading the questions and planning what I was supposed to write. The term test is a warning that the lack of comprehension is the main reason of writing speed. Therefore, I need to do more practices about writing codes. Also, We have an assignment which is due right after the reading week. The assignment is quite interesting and it's related to our real life. I decide to work alone on this assignment because it provides a great opportunity on practice writing codes instead of doing assigned works by working with groups. Furthermore, the Q&A posted on piazza would be helpful when I write the assignment and hopefully I will get all this done by the end of the reading week.