2015年3月29日星期日
#week 11 A look back
With the final week approaching, this term is almost over and we learned a variety of methods in csc148. It's worthwhile to take a look back on all the slogs. I find that I improve my skills through writing summaries.
As what I wrote in my first slog (why should geeks write), writing articles is able to improve our skill of explanation. When it comes to the team work of those assignments, it's crucial that you can explain what you think to your teammates and it will contribute to find a way to solve the complicated problems and complete the assignment more quickly. We always discuss for the assignment and things that are abstract.
I mentioned that I found it rather hard to write recursions on my earlier slogs. After that, I wrote some summaries on recursions after I reviewed the course materials and searched related materials online. And I also make summary on other topics and Whenever I get stuck on writing certain part of codes, I will look back on the related summary. It sometimes helps a lot, although not every time.
I look at others' slogs as well and learned a lot from some outstanding summaries.
In conclusion, I find that writing slogs not only improves the skill of clear explanation but also improves my academic performance.
Here are some links:
http://questionablecsc146decisions.blogspot.ca
http://dogthatslogsthroughthefog.blogspot.ca
2015年3月26日星期四
Week 10 #the impression of week 9
This week we looked back at assignment 2 and made some summaries.
The assignment focuses on two parts, one is minimax, and the other is apply move. At first, our team has no idea about how it works and struggled at writing minimax. We even found our minimax was less smart than the random one, which was rather frustrating. Then we try to draw the picture first and find a way to make the computer be smart.
The assignment focuses on two parts, one is minimax, and the other is apply move. At first, our team has no idea about how it works and struggled at writing minimax. We even found our minimax was less smart than the random one, which was rather frustrating. Then we try to draw the picture first and find a way to make the computer be smart.
The minimax plays the game for us. We use recursions to max the possibility to win and if there is no chance to win (such as the other player fills the middle blank in a 3*3 lattice) we want the result to be at least tie.
After writing the codes, we played the game in 3*3 lattice but we found that if we had not filled the middle blank at first, the computer did not always choose the middle blank which is opposed to what we assumed before. Then we tried to fix this problem but always in vain. Eventually, we find out that if we assume both players are using minimax and the computer is the second player, the computer can't win in this 3*3 lattice even if it fills the middle blank first and in this case the best result is tie.
And we used deep copy in this assignment which was googled online. Besides minimax, other functions are easier to write compared to the minimax. We get all the possible moves and use if to judge whether a certain move is legal.
I think this is a brilliant practice and a very challenging one.
I was looking at others' slogs and learned something from them.
Here is some links.
http://christiangarciacsc148.blogspot.ca/2015/03/week-10-impressions-of-week-9.html
http://www.mybigfatcsc148slog.blogspot.ca
2015年3月15日星期日
Week 9 Impression of week 8
We focused on the LinkedList these days. LinkedList is a class as a list make up of a value and a sub-list. Or we can think it the other way and consider it as an object with a value and a reference to other similar objects.
It will be much easier to understand the codes if we can draw pictures for LinkedList.
We will find the codes below quite useful for tracing the values of the LinkedList.
cur_node = self.front
while <some condition here...>:
# do something here...
cur_node = cur_node.nxt
If the mutation does not only relate to the current nodes but also relate to the previous nodes. (For example, delete_back) We will find the codes below quite useful.
prev_node, cur_node = None, lnk.front# walk along until cur_node is lnk.back while <some condition>:prev_node = cur_nodecur_node = cur_node.nxtWhen we mutate the LinkedList, we will probably change the variables like self.front, self.back, self.size, self.value and self.nxt. What can't be ignored is that it's confusing when we change some variables and the best way to make it less complicated is drawing clear pictures carefully.When it comes to adding a brand new node, we need to create a new node by writing LLNode(value,nxt) and link it with the previous node and the next node.
2015年3月8日星期日
Impressions of week #7
This week we focus on the BTNodes and Linked lists. These are special classes. In Professor Danny's ppt, he mentioned that most of the work of special methods is done by the nodes "__repr__", "__str__" and "__eq__".Once these are done for nodes, it's easy to do them for the
entire list.
1. BTNodes
1. BTNodes
Binary tree code has two children which are in order, the left one and the right one.
eg:
b = BTNode(8, BTNode(4, BTNode(2, None, None), BTNode(6, None, None)), BTNode(12, None, BTNode(14, None, None)))
print(b)
14
12
8
6
4
2
So when we write some recursions linked with BTNodes, we need to pay much attention to the children. What we usually do is operating the left tree and operating the right tree and combining them. And when it comes to list_between(node, start, end), we do not have to compare all the data in the node because data in left subtree are less than node.data and data in right subtree are more than node.data .
2. LLNode
Linked lists are lists made up of an item (value) and a sub-list (rest). And the objects (nodes) have a value and a reference to other similar objects.
eg
>>> n = LLNode(5, LLNode(7))
>>> print(n)
5 -> 7 ->|
In order to make a reference to the node and move it along the node, what we usually do is using the codes below:
The Linked list nodes can be quite confusing and we shall always draw pictures to make the situations much more clear. And what can't be ignored is that once we change the LinkedList, we need to change last node, former last node, back, size and possibly front.
eg:
b = BTNode(8, BTNode(4, BTNode(2, None, None), BTNode(6, None, None)), BTNode(12, None, BTNode(14, None, None)))
print(b)
14
12
8
6
4
2
So when we write some recursions linked with BTNodes, we need to pay much attention to the children. What we usually do is operating the left tree and operating the right tree and combining them. And when it comes to list_between(node, start, end), we do not have to compare all the data in the node because data in left subtree are less than node.data and data in right subtree are more than node.data .
2. LLNode
Linked lists are lists made up of an item (value) and a sub-list (rest). And the objects (nodes) have a value and a reference to other similar objects.
eg
>>> n = LLNode(5, LLNode(7))
>>> print(n)
5 -> 7 ->|
In order to make a reference to the node and move it along the node, what we usually do is using the codes below:
cur_node = self.front
while <some condition here...>:
# do something here...
cur_node = cur_node.nxt
2015年3月1日星期日
Abstract Data Types and recursion
Abstract Data Type is a certain mathematical model for a certain class of data structures that have similar behavior. (from the definition on the wikipedia) In Professor Danny's class, Danny has described the common ADTs ---- in CS we recycle our intuition about the outside word as ADTs. We abstract the data and operations, and suppress the implementation. And he divides it to three types:
1. Sequences of items; can be added, removed, accessed by position.
2. Specialized list where we only have access to most recently added item.
3. Collection of items accessed by their associated keys.
(from Danny's ppt)
We have discussed several examples in order to understand it. (Stacks, Queues(in lab), Trees etc)
These weeks we are focusing on class Trees. The Tree has children and values and we named the children who has no child leaves. And the BTNode is a binary Tree code which has left children and right children. When it comes to BTNode's leaves, we have the left children and the right children are both equal to None.
And we combine recursion with the class BTNode which is a bit confusing. Let me make an example.
We recall the function list_longest_path itself to solve the problem. We first consider the easiest two conditions and then we extend it to the complicated conditions.
1. Sequences of items; can be added, removed, accessed by position.
2. Specialized list where we only have access to most recently added item.
3. Collection of items accessed by their associated keys.
(from Danny's ppt)
We have discussed several examples in order to understand it. (Stacks, Queues(in lab), Trees etc)
These weeks we are focusing on class Trees. The Tree has children and values and we named the children who has no child leaves. And the BTNode is a binary Tree code which has left children and right children. When it comes to BTNode's leaves, we have the left children and the right children are both equal to None.
And we combine recursion with the class BTNode which is a bit confusing. Let me make an example.
We recall the function list_longest_path itself to solve the problem. We first consider the easiest two conditions and then we extend it to the complicated conditions.
订阅:
博文 (Atom)



