2015年3月7日星期六

SLOG 6

This week we learnt an interesting new thing called tree. Tree looks like this:
Thumbnail for version as of 18:57, 16 February 2011
We can utilize this picture to analysis the concept of Tree. On the top, we see a node (2) with no parent but with children. This is a root. At the bottom, we can find nodes(5,11,4) with no children, and they are called leaves. A subtree is defined as trees that are formed by any tree node together with its descendants and the edges leading to them.
We are also given the concept height, depth and arity, branching factor. 
In this picture, the longest path is 2----5----9----4(or 2----7-----6----5 or 2----7-----6----11), so the height of this tree is 4. The height of a node, for instance, 6,is 3,since the maximum path to the root is 6----7----2.
The depth of a node means the height of the entire tree minus the height of a node. For example, the depth of 6 is 1,since the height of the entire tree is 4,and its own height, as we mentioned above, is 3.
Artiry, branching factor is an interesting concept. It means the maximum number of children. It is a kind of restriction. Sometimes that will be more restrictive: sometimes the right children must be larger than the left children.

This week we also learnt things about LinkedList. Basically, it is a connected list, which is connected node by node. Simply, it can be considered as a tree whose branching factor is 1. But it is not that simple as it looks like.
Generally, LinkedList is expressed in this way: 3 ->2->1->0|, which means the list [3,[2,[1,[0] ] ] ]. There are some relationship among the different parts in this list.
Wrapper class is very important for LinkedList, because LinkedList is list and we have to know its size. Size is not supposed to be in an individual node, and wrapper class can help us find the size since it can turn a single node into the whole list. Usually, we have the information of the front list and back list in a LinkedList. (front: LLNode -- front of list
back: LLNode -- back of list)
We also mentioned the method to iterate a LinkedList. There are two ways to realize it, which are, respectively, while loop and recursion. While loop is what we learnt in CSC108, and we have to focus on recursion in this course.

Here is some methods that I conclude to solve this recursion problem: No matter what we do to the LinkedList, for instance, append or delete, we have to keep an eye on its front and back Node. When appending, we have to record the Node one space ahead the Node that we are operating now. When deleting, we only need to connect the front node and the back node.

This week the assignment 2 is out as well, and my partner and I are trying to solve the problems. We are now confused about how to express the rules of the game by codes.

没有评论:

发表评论