Sunday, 5 April 2015

Week 12 Last impressions

    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.

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.

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:

  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.

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:

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.