The wave of strike seems to be still high and keep rising. As a consequence, we have no choice but to gain some of the knowledge and do exercises by ourselves.
First I need to talk about Test 2 which was finished this week. As I have mentioned before, the strike could never prevent us from gaining knowledge and doing relevant exercises, tests included. So the test went as planned and I worked very hard for the test. Based on what we have learned recently, Test 2 mainly contained the idea of Tree (Binary Tree included) and LinkedList, which could be regarded as a special Tree. There is no doubt that both of them presented the idea of connection between elements in different levels, and lower levels were connected to the upper ones all the time. From this point, recursive thinking is often applied to solve these problems. However, as long as you figure out the basic condition and how each levels are connected, it could be easy to solve recursive functions, and, do well in Test 2. My job was not bad, but still not enough!
Besides, though the test was over, learning can not stop. Actually I gain deeper understanding for recursion and Tree class from the test, and I would apply it as much as possible in the further learning, for example, the coming Assignment 3.
Due to the strike, the marking of Test 2 might be delayed more or less. Anyway, good luck to all of you!
Sunday, 15 March 2015
Sunday, 8 March 2015
SLOG5: Impression of the week
In the last week a TA strike attacked the whole school and we lost many labs and tutorials, CSC148 lab included. However, the learning of CSC148 course would never stop during these reasons, and perceiving and grasping new knowledge would keep going on, too.
This week we learned a new concept named "linked list", which is similar to but not the same as the concept of tree. Though they both use "nodes" as a super level and contain elements called "leaves" in the sublevel via each list, and elements in lists could be other nodes at the same time, the number of nodes in the list of linked list could only be one. That means, every node contains an element and a list which contains another single node. That is quite interesting since elements are not standing as a line simply. Instead, each two nearby elements are connected tightly and if you delete the form node then the latter one would vanish.
The concept of linked list provides a different option for us to storage elements like integers, floats, strings and so on. In the past we may tend to storage what we want by using list, tuple and dictionary. Yet none of them may create a connection between every two elements. Now via linked list we could achieve it easily, which may make a difference in the future learning and coding.
The other thing is that Assignment 2 was due this week. I cannot deny that during the past two weeks I spent the majority of my after-class time to work for this assignment. At first I really met lots of trouble, such as the form of a move, the storage of current places of checkers, the judgement of rough outcome and the idea of minimax strategy. In particular, I really had no idea how to design a strategy for the computer when I got the handout. With tough working, thinking and coding, I solved each them gradually and eventually complete the whole assignment. Though the strategy is not perfect, I tried my best and make it matter for most cases.
We will face Test 2 in the next week. Tough what will be shown in the test is certainly more difficult, I believe I could get them with sufficient exercise. Good luck to every geek in CSC148!
This week we learned a new concept named "linked list", which is similar to but not the same as the concept of tree. Though they both use "nodes" as a super level and contain elements called "leaves" in the sublevel via each list, and elements in lists could be other nodes at the same time, the number of nodes in the list of linked list could only be one. That means, every node contains an element and a list which contains another single node. That is quite interesting since elements are not standing as a line simply. Instead, each two nearby elements are connected tightly and if you delete the form node then the latter one would vanish.
The concept of linked list provides a different option for us to storage elements like integers, floats, strings and so on. In the past we may tend to storage what we want by using list, tuple and dictionary. Yet none of them may create a connection between every two elements. Now via linked list we could achieve it easily, which may make a difference in the future learning and coding.
The other thing is that Assignment 2 was due this week. I cannot deny that during the past two weeks I spent the majority of my after-class time to work for this assignment. At first I really met lots of trouble, such as the form of a move, the storage of current places of checkers, the judgement of rough outcome and the idea of minimax strategy. In particular, I really had no idea how to design a strategy for the computer when I got the handout. With tough working, thinking and coding, I solved each them gradually and eventually complete the whole assignment. Though the strategy is not perfect, I tried my best and make it matter for most cases.
We will face Test 2 in the next week. Tough what will be shown in the test is certainly more difficult, I believe I could get them with sufficient exercise. Good luck to every geek in CSC148!
Sunday, 1 March 2015
SLOG4: Recursion
As the processing of the course CSC148, we have grasped several essential concepts and skills of coding. Recursion, as the latest but a crucial kind of method for us, is showing how efficient and effective it is to us. There is no doubt that recursion method really presents the strong function of computer programs.
In computer science any object or class or method could apply recursion approach as long as they could treat a set of possible cases somehow towards the base case(s). Therefore, the most important identity of recursion is that it could treat numerous conditions (e.g. every state in a game) with only a few lines of codes. Inside these lines the function itself would be recalled until the final conditions are arrived. The process could be so long but we could throw it into a recursion and let it deal with the situation for us within seconds.
As I have mentioned in last week's SLOG, a Tree class could exhibit recursive behaviour since there are two basic cases: if there is only one number, then we call it a leaf; else if it contains a number and one another list and the list is non-empty, then we call it a node. For those nodes cases we could always treat it towards leaves via using recursion, which means a function that could call itself while running. Since the basic element of node is the leaf, we could let the recursion function call itself if the variable of the function is a node until every variable we meet is a leaf.
The application of recursion could even be further. During the last two weeks we were concentrating on CSC148 Assignment 2, which includes a strategy called Minimax. It requires us to consider all possible states when a move is applied in a game state. Here we could divide conditions into several cases: win, lose, tie, or the game is not over. For the last one it is a sound choice to use recursion to make the assumption until the game is thought to be (but not actually be) over, and then we could judge whether the player would win or not and therefore decide which move for the current player has more opportunities to win. Since it is impossible for us to list out all the states step by step, recursion is efficient enough for us to make it. For every possible moves we could analyze the first step by ourselves and then apply recursion to "make" (assume to make) next possible moves until the game is over and there is no more possible moves. After that, what we need to do is only returning the max score for the final state of every possible move we analyzed at first. Here we omit doing numerous analyzing manually and give this task to the recursion.
Grasping recursion is also an essential harvest for me. In the past, the only method I could come up with to cope with problem that need to execute some commands more than once was the loop. Yet the definition of loop decides that it could only be applied to solve those simple problems which only need to repeat some identical and simple codes and conditions. Now with knowledge of recursion I am able to tackle more complicated conditions with changing antecedents and variables such as the states of one processing game. I could even say that recursion makes my codes become more intelligent!
The assignment would due in next week and there is not much time for me to complete it. I believe that as I finish it thoroughly I would gain more understanding of recursion and could use it more in the future studying.
In computer science any object or class or method could apply recursion approach as long as they could treat a set of possible cases somehow towards the base case(s). Therefore, the most important identity of recursion is that it could treat numerous conditions (e.g. every state in a game) with only a few lines of codes. Inside these lines the function itself would be recalled until the final conditions are arrived. The process could be so long but we could throw it into a recursion and let it deal with the situation for us within seconds.
As I have mentioned in last week's SLOG, a Tree class could exhibit recursive behaviour since there are two basic cases: if there is only one number, then we call it a leaf; else if it contains a number and one another list and the list is non-empty, then we call it a node. For those nodes cases we could always treat it towards leaves via using recursion, which means a function that could call itself while running. Since the basic element of node is the leaf, we could let the recursion function call itself if the variable of the function is a node until every variable we meet is a leaf.
The application of recursion could even be further. During the last two weeks we were concentrating on CSC148 Assignment 2, which includes a strategy called Minimax. It requires us to consider all possible states when a move is applied in a game state. Here we could divide conditions into several cases: win, lose, tie, or the game is not over. For the last one it is a sound choice to use recursion to make the assumption until the game is thought to be (but not actually be) over, and then we could judge whether the player would win or not and therefore decide which move for the current player has more opportunities to win. Since it is impossible for us to list out all the states step by step, recursion is efficient enough for us to make it. For every possible moves we could analyze the first step by ourselves and then apply recursion to "make" (assume to make) next possible moves until the game is over and there is no more possible moves. After that, what we need to do is only returning the max score for the final state of every possible move we analyzed at first. Here we omit doing numerous analyzing manually and give this task to the recursion.
Grasping recursion is also an essential harvest for me. In the past, the only method I could come up with to cope with problem that need to execute some commands more than once was the loop. Yet the definition of loop decides that it could only be applied to solve those simple problems which only need to repeat some identical and simple codes and conditions. Now with knowledge of recursion I am able to tackle more complicated conditions with changing antecedents and variables such as the states of one processing game. I could even say that recursion makes my codes become more intelligent!
The assignment would due in next week and there is not much time for me to complete it. I believe that as I finish it thoroughly I would gain more understanding of recursion and could use it more in the future studying.
Subscribe to:
Posts (Atom)