2015年4月3日星期五

Revisit

After looking back to all the slogs that I had written, I have to say that i have change my mind about writing slog. I used to think it is useless. The only reason I write it is that TA marks it seriously. However, I see some progress on it. I look back to my first slog, why geek needs to write. I am admitted that it is a very bad slog with no critical thinking and no point.  It only gets 33%. After the first slog, I tried my best to write the slog on time and tried to think more when I wrote it. So, in the blog, summary of recursion, I saw myself having some thinking in it. In that blog, I talked about how I figure out the program. I talked about finding the basic case and finding how the program recurs. That means that I really tried to write the slog better.
Secondly, I also looked at others blog. Some of them stop updating their blog. I guess they may drop the course because some of my friends drop it since they were not doing well in the midterm and assignment. However, there are still some good slogs that are keeping updating their blog. For example, I have visited the blog (http://csc148slog1001429162.blogspot.ca). To be honest, his slog is way better than mine. In his second last blog, he talks about Binary Search Trees and some methods about it. His idea about how the delete method works helps me to understand it. And his blog about recursion is also talking about the best way to make recursion easier to think, which is writing the basic case firstly. I can tell that the owner of this blog is doing very well on csc148 because he has his own thinking on some key knowledge such as recursion and ADT. He also talks about that Computer science is much more than coding. I agree with that. Sometime when I feel hard to write the code, I just have no idea of the logical thinking. After I know the logic and how the program works, it is very easy to write the code quickly and correctly. 

In conclusion, writing slog is not only helping me to collating my knowledge about csc148, but also forces me to think more and creative.

2015年4月1日星期三

Slog of ninth week

I  would like to talk about the assignment 3 in this slog.
Our group choose to do the option A.
There are 3 things we need to do about the optionA.
The first things is the minimax_memorize. It needs us to record the game state that the function meet . How i deal with it is to create a dictionary and record the game state in the suggest_move. Also, before apply move, we need to check if our dictionary has that game state. If it has , then the function will return the move recorded in the dictionary.
The second methods is to avoid investigating moves that i know will not change the result. Those moves wastes so much time. I got nothing to say about this methods because we just followed the instruction given by Denny. It is not hard.
The last one is wired. We need to limit the moves that the program will look ahead. So we  need to stop the recursion program when moves it look forward is bigger than n. In our recursion program, when n is bigger than like 10, the recursion program will call the rough_outcome program to estimate the score of the game state.

2015年3月27日星期五

Slog of eighth week

The lecture this week talked about the information of the term test and class binary search node.

class BTNode:     ’’’Binary Tree node.’’’
    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


If I want to insert a data in a BTNode, I need to be carful about the condition that the BTNode is none. If it is none, then the function needs to return a new BTNode with the data I want to insert. If the BTNode is not none, I will meet 3 conditions. The data is bigger, smaller than the data in the BTNode or equal to the data in the BTNode. When it is bigger, I let the right side to do the recursion. When it is smaller, I let the left side to do the recursion. When it is the same, I won't do anything.

slog of seventh week

This week, the topic we learned about was class  LLNode, to represent linked list nodes, and class LinkedList, to represent an entire linked list. This Node is somewhat similar with the node class we have learnt before. The code of those two class is following:

class LLNode:
    ’’’Node to be used in linked list
    nxt: LLNode -- next node
                   None iff we’re at end of list
    value: object --- data for current node
    ’’’
    def __init__(self, value, nxt=None):
        ’’’ (LLNode, object, LLNode) -> NoneType
        Create LLNode (self) with data value and successor nxt.
        ’’’
        self.value, self.nxt = value, nxt
 class LinkedList:
    ’’’Collection of LLNodes
    front: LLNode -- front of list
    back:  LLNode -- back of list’’’
    def __init__(self):
        ’’’ (LinkedList) -> NoneType
        Create an empty linked list.
        ’’’
        self.front, self.back = None, None
        self.size = 0
The process of LL looks like the process of  bubble sort. We need to use the while loop to control the program to find the node that we want to delete or insert.
We don't have lab this week since the strike. 

2015年3月1日星期日

Summary of recursion

In the pass 4 week, i have learned a lot of knowledge about recursion, which is totally new to me.

What I learned first to get knowledge of recursion was about tracing the recursion. In the lab 3, i was given some functions. Here is the Example,

def count_elements(L):
    ’’’(list or non-list) -> int
    Return 1 if L is a non-list, or number of non-list elements in
    possibly-nested list L.
    Assume: L is any Python object.
    # examples omitted!
    ’’’
    if isinstance(L, list):
        return sum([count_elements(x) for x in L])
    else: # if L is not a list, count it
return 1 

When i want to trace  count elements([7, [2, 1, 3], 9, [3, 2, 4]]), the first thing I need to do is to deal with the basic list. The basic list is [7, [2, 1, 3], 9, [3, 2, 4]. After the first step, what we get is sum(1,count_elements([2,1,3]),1,count_elements([3,2,4]). And then , after the step tracing, what we can get is sum(1,sum(1,1,1),1,sum(1,1,1)). Finally, we get sum(1,3,1,3) = 8.. As i described, this is how recursion work. Unlike the function i learned in the pass, the recursion function will recall itself once and once again.

After learning how does recursion work, i study to learn how to write a recursion function, which is hard for me.
We studied how to write the recursion function by introducing Tree and BTnode.
For example, in the quiz5, I need to count the internal nodes of a tree, Tree(17,[tree(2)[tree(5),tree(6),tree(7)],tree(3)[tree(8),tree(9)],tree4)
This tree is look like that,
                17
2               3             4
567           89
As we can see, the num of internal node is 3. They are 2, 3, 17.
In order to write the recursion, i was told by the TA that, i need to study by the basic example.
The basic example is Tree(17), which have no children so that it is not a internal node. So, is a tree have no children, the function will return 0. How thing goes when we get Tree(17, [tree2])? This tree have one children, and the function will return 1. What about a tree likeTree(17,[tree(2)[tree(5),tree(6),tree(7)],tree(3)[tree(8),tree(9)],tree4). Every time we get a node, we will count 1. The function should be something like . 1+***(function(x) for x in tree.chirdren). And we know there are node in the children of the basic tree, then we need to calculate the sum of them. So the function will be 1+sum(function(x) for x in tree.chirdren)
So, when it comes to how to write a recursion function, the most important thing is the basic example. After doing that, it will be much easy to write the function. 

2015年2月7日星期六

impressions of tracing recursion from week 4

The tracing recursion is very important in computer science. We do a lot of exercise in the lab, which was very fun. It seems very easy when i first saw it . However, when i wanted to explain why i got those result, i will need to do it step by step. Sometime i will be confuse about when to use the function again. When i need to use recursion to write function, i made some mistake and i can't deal with it that time but i figured it out when i went back t my resident. Anyway, recursion is fun.

impression of first few weeks

Before this semester, i thought the csc148 course will just like the csc108. However, there are so much difference between them. Unlike the csc108, the csc148 is more difficult. It does not offer student with video and prepare exercise and perform exercise, which means student need to do those thing on their own. And the assignment of csc148 is more harder. It require student to do it without guild like csc108 offer. However, the lab of csc148 can help student to be more familiar with the knowledge learned in the lecture.