Finally, CSC148 has come to an end. Honestly speaking, I really enjoyed this class. CSC148 and CSC108, which I took last term have actually kind of brought me into the world of computer science.
Instead of paying most of the attention to functions in CSC108, we started to emphasize more on class this term. I've learned the significance of abstract data type, problem solving algorithms and also efficiency. Class has opened a wide window for us so that we can create our own data types. Recursion is an elegant way of solving problems by breaking them into subproblems, and it's challenging and requires more thinking. Object-oriented programming is a programming paradigm based on the concept of "objects", which are data structures that contain data. Linked list a linear sequence of nodes, each with a value a reference to the next node.
The lab is quite a nice way of learning for me. We have two hours to work on some codes in the lab every week and it's a good practice besides lectures which helps us understand the knowledge better. Moreover, we have opportunity to ask the TAs for help and also know some fellow students in computer science too.
Regarding the assignment, this is really a tough part of this course. All of the 3 assignments we did this term were challenging. I worked together with my partners. We discussed about the ways to solve problems, the efficiency, etc and during this process, in fact, we learned a a lot. Just like what I wrote in the first week, geeks need to write and communicate.
The last thing I want to say is that this is fantastic and enjoyable learning experience for me. I appreciate all the help I got this term, from the TAs, my fellow students and especially Danny. Thank you all for leading me into the world of computer science and I'll keep going and hang on.
Sunday, 5 April 2015
Monday, 30 March 2015
Week 11 Recursion
In this semester, we learned pretty much about recursion. It used to be a completely new concept to me, and it was even hard to understand at the beginning, but after doing much practice, I now find it concise and, even beautiful!
I revisited my impression about recursion which I wrote a few weeks ago. It turns out that I actually knew the definition well at that time. As I wrote in the blog, recursion is a method of solving problems that involves breaking a problem down into smaller and smaller subproblems until you get to a small enough problem that it can be solved trivially. Usually recursion involves a function calling itself.
However, now I'm starting to get used to it more and think about whether it'll be better to use recursion in the code. Instead of only memorizing the definition, I find it more practical in some coding work. In fact, recursion can just solve the problem in much fewer codes rather than writing several lines of 'for loop' and 'while loop', which is absolutely its advantage. While it may not seem like much on the surface, recursion allows us to write elegant solutions to problems that may otherwise be very difficult to program. And recursion is proved to be super effective in the class such as Tree and BTNode which we did this semester. It's also a crucial method in A3 that we're working on now.
I revisited my impression about recursion which I wrote a few weeks ago. It turns out that I actually knew the definition well at that time. As I wrote in the blog, recursion is a method of solving problems that involves breaking a problem down into smaller and smaller subproblems until you get to a small enough problem that it can be solved trivially. Usually recursion involves a function calling itself.
However, now I'm starting to get used to it more and think about whether it'll be better to use recursion in the code. Instead of only memorizing the definition, I find it more practical in some coding work. In fact, recursion can just solve the problem in much fewer codes rather than writing several lines of 'for loop' and 'while loop', which is absolutely its advantage. While it may not seem like much on the surface, recursion allows us to write elegant solutions to problems that may otherwise be very difficult to program. And recursion is proved to be super effective in the class such as Tree and BTNode which we did this semester. It's also a crucial method in A3 that we're working on now.
Sunday, 22 March 2015
looking back at a2
In this week's lecture, we looked back at A2.
First, we talked about how to get the apply_move right. In order not to change the GameState according to the type contract, a new method called deep copy was introduced. We use deep copy to make a copy at every level so that we won't inadvertently change the GameState.
Second, we did something about testing minimax. Basically the call looks like:
First, we talked about how to get the apply_move right. In order not to change the GameState according to the type contract, a new method called deep copy was introduced. We use deep copy to make a copy at every level so that we won't inadvertently change the GameState.
Second, we did something about testing minimax. Basically the call looks like:
sm = StrategyMinimax() sm.suggest_move(SubtractSquareState(?, ?))
The important idea is that if one test case passes, it doesn't necessarily mean that the minimax worked well because there is a possibility that it can be passed by a random strategy too. So for example, we tried some test cases in the lecture. It turns out that some of the game state will lead a win for one person no matter what move he chooses. In this situation, minimax won't be tested effectively. However, some game state with some moves leading to a win and some moves leading to a loss is better because the player will certainly win if he uses minimax. When he chooses random move, he's not guaranteed to win or lose.
Midterm
Time to test ourselves!
We had the midterm this week. There're 3 questions on it covering Tree, Linked list, etc. The first question asks us to draw two binary trees with 20 nodes -- one tallest and one shortest. That should be easy if we know well what a binary tree is. And we were also tested on what preorder search is. The second question is mostly about recursion, which used to be a new and pretty confusing thing to me, but now it is not. The last one is about linked list.
We had the midterm this week. There're 3 questions on it covering Tree, Linked list, etc. The first question asks us to draw two binary trees with 20 nodes -- one tallest and one shortest. That should be easy if we know well what a binary tree is. And we were also tested on what preorder search is. The second question is mostly about recursion, which used to be a new and pretty confusing thing to me, but now it is not. The last one is about linked list.
Sunday, 8 March 2015
Impressions of Linked List
As what we learned in this week, linked list a linear sequence of nodes, each with a value a reference to the next node. What's more, we keep reference to the front and back of the sequence. We defined two classes in the program, which is LLNode and LinkedList. LLNode represents a single node and LinkedList represents the linked list as a whole, which can be called a wrapper class. Regarding wrapper class, it means that we can bundle information about the overall linked list. Moreover, an empty linked list is an instance of the class, with attribute values set to show it's empty.
There are three important thins about linked list. One is traversing a linked list. Following is a common pattern:
There are three important thins about linked list. One is traversing a linked list. Following is a common pattern:
current = self.front
while <some condition holds>:
<Do something with the current node.> # Advance to the next node. current = current.nxt
Another thing is mutating a linked structure. Since code that mutates an existing structure is easy to mess up, we are strongly recommended to draw pictures, which helps us understand it better.
The last thing we need to pay attention to is the problem of going to far. For some methods, once we've found what we are looking for, we have gone too far to make the changes we want. An useful solution to this is to walk two references along the list, with one trailing behind a step.
Sunday, 1 March 2015
abstract data type
In my perspective, abstract data type is a model for a certain class of data types that have similar semantics (the meaning of real-world entity being represented as is showed in the course note). It puts more emphasis on the intended meaning of
the data it stores, and the operations it provides on that data instead of talking about the how to store and
manipulate the data in a particular programming language.
As what we learned in lectures in these weeks, it's obvious that it has its own advantages. One of it is that We can think about algorithms, or recipes, for solving problems more freely if we don't have to include
all the details of how our objects are implemented. Moreover, details of how objects, and their components, are stored and accessed vary between programming
languages, whereas a really good algorithm can be translated into any programming language. And stack is a good example which we have learned before.
Thursday, 19 February 2015
Object-Oriented Programming
Object-oriented programming is a programming paradigm based on the concept of "objects", which are data structure that contain data, in the form of fields, often known as attributes; and code, in the form of procedures, often known as methods. It attempts to provide a model for programming based on objects and a distinguishing feature of objects is that an object's procedures can access and often modify the data fields of the object with which they are associated.
As what we learned in lectures in these few weeks, the class Stack is a good example. In this class, one of the most attractive features is that it is a last-in, first-out stack of items (LIFO). We can regard it as a real book stack from which we can take and put a book on the top of the stack. Obviously the books are just like the objects. In fact, there are methods in it called 'pop', which aims to pop and return the top item in the Stack; 'push', which aims to place the object on the top of the Stack; and 'is_empty', which checks whether the Stack is empty. These three methods enable us to access and modify the data fields of objects.
I'm more than excited to learn more about the object-oriented programming language Python.
As what we learned in lectures in these few weeks, the class Stack is a good example. In this class, one of the most attractive features is that it is a last-in, first-out stack of items (LIFO). We can regard it as a real book stack from which we can take and put a book on the top of the stack. Obviously the books are just like the objects. In fact, there are methods in it called 'pop', which aims to pop and return the top item in the Stack; 'push', which aims to place the object on the top of the Stack; and 'is_empty', which checks whether the Stack is empty. These three methods enable us to access and modify the data fields of objects.
I'm more than excited to learn more about the object-oriented programming language Python.
Sunday, 8 February 2015
Impression of recursion
In the last few weeks, we learned about recursion. Actually when I saw this word, things that came to my mind first are 'for loop' and 'while loop'. After the lecture, I found that in fact, it's more concise and, even beautiful!
Recursion is a method of solving problems that involves breaking a problem down into smaller and smaller subproblems until you get to a small enough problem that it can be solved trivially. Usually recursion involves a function calling itself. While it may not seem like much on the surface, recursion allows us to write elegant solutions to problems that may otherwise be very difficult to program. Instead of writing several lines of 'for loop' and 'while loop', recursion can just solve the problem in much fewer codes, which is absolutely its advantage. However, I also came up with the problem that sometimes it may take more time to work out a recursion than just to use a for loop or while loop. Anyways, it's a great way to solve big problems and I'm sure it'll be useful in our future learning.
Recursion is a method of solving problems that involves breaking a problem down into smaller and smaller subproblems until you get to a small enough problem that it can be solved trivially. Usually recursion involves a function calling itself. While it may not seem like much on the surface, recursion allows us to write elegant solutions to problems that may otherwise be very difficult to program. Instead of writing several lines of 'for loop' and 'while loop', recursion can just solve the problem in much fewer codes, which is absolutely its advantage. However, I also came up with the problem that sometimes it may take more time to work out a recursion than just to use a for loop or while loop. Anyways, it's a great way to solve big problems and I'm sure it'll be useful in our future learning.
Saturday, 31 January 2015
A new start
To be honest, I'm not good at programming at all when I decided to be a computer science student in the university. Unlike some fellow students who have already learned several computer programming language like Java or C, I'm kind of like a soldier on the battlefield who doesn't even know how to fight.
So why do I take computer science as my major? Well, because I believe computer science is really useful and essential in our life. Nowadays, people can't live without 'computers'. I mean, not only computers or laptops, but also mobile phones, iPods, TVs, etc. Moreover, I believe that what we're learning now, like the efficiency of algorithm, can also be applied into many other fields, such as economics.
I have to admit that there are a lot of 'geeks' in my fellow students who are good at computer science, and that's why I called it a battlefield. So I have to make much more effort in study.
No pains, no gains.
It is a new start and I'm sure it will be tough, but I won't give up.
So why do I take computer science as my major? Well, because I believe computer science is really useful and essential in our life. Nowadays, people can't live without 'computers'. I mean, not only computers or laptops, but also mobile phones, iPods, TVs, etc. Moreover, I believe that what we're learning now, like the efficiency of algorithm, can also be applied into many other fields, such as economics.
I have to admit that there are a lot of 'geeks' in my fellow students who are good at computer science, and that's why I called it a battlefield. So I have to make much more effort in study.
No pains, no gains.
It is a new start and I'm sure it will be tough, but I won't give up.
Tuesday, 20 January 2015
Why geeks should write?
When talking about Computer Science, the very first thing that come to many people's mind is programming, which is certainly true to some extent. While I have to say that actually Computer Science is not all about programming or coding, which make us look like 'geeks' who stay with a computer for all day and never talk to anyone. Instead, we should write, not only codes.
Why do we learn Computer Science? In my opinion, we learn it to make the world better. To be more specific, we learn it to make the machines, computers, etc around us work more efficiently and effectively. Sometimes we may have some nice ideas to do it, but I think communication is the key point. Only when we are able to communicate our ideas to others can we possibly make the world better. We need to persuade others that our idea is feasible and worths advocating by letting them understand what we are doing,why we are doing this and how we are doing this so that they can see the value of our work. Otherwise, the brilliant idea in our mind may only stay there alone, then languish and be buried.
By writing, we learn to communicate. By communicating, we make the world better.
Why do we learn Computer Science? In my opinion, we learn it to make the world better. To be more specific, we learn it to make the machines, computers, etc around us work more efficiently and effectively. Sometimes we may have some nice ideas to do it, but I think communication is the key point. Only when we are able to communicate our ideas to others can we possibly make the world better. We need to persuade others that our idea is feasible and worths advocating by letting them understand what we are doing,why we are doing this and how we are doing this so that they can see the value of our work. Otherwise, the brilliant idea in our mind may only stay there alone, then languish and be buried.
By writing, we learn to communicate. By communicating, we make the world better.
Subscribe to:
Posts (Atom)