Monday, 6 April 2015

Week #12: last impressions

Finally, this semester comes to an end and this is my last slog. Look back over this course, it's totally different from csc108 and csc165, which first gives me impression of what computer science is about. From the very beginning of the class, we learned about abstraction data type, and then applying it in python along with some methods as well as inheritance and exception, etc. Then, we use these knowledge to write a subtract square game as our assignment 1, which is the first time that all the step is determined by ourselves, and frustrated me a lot. It gave me the impression that this course is so hard, however, surprisingly, I got a good mark in the first test, which brought my confidence back.
After that, we learned about the recursion with list comprehension and how to apply it into a tree class and linked list class. This part is the most difficult through the course as well as on the test because we have to be extremely familiar with the recursion part so that we are able to write codes on paper correctly without testing it. I've complained much about recursion in my previous slogs, but still practice a lot is very necessary. About recursion, we have it for minimax from assignment 2 and for almost every function from assignment 3. We suffered a lot doing those assignments but if we think in another way, those exercise help us improving recursion a lot.
Last but not least, we talked about the efficiency part. It is easy compared with the previous parts as it was mentioned a lot in csc165. We got the idea that in which way is more efficiency, which will be used in the future.
Overall, I feel very happy for learning lots of new knowledge about computer.

Sunday, 29 March 2015

week #11: revisit an earlier slog

This week we have an assigned topic which is to revisit an earlier slog to see what have been changed in our mind. I will revisit my third slog, which is the impression of tracing recursion. At that time, I said that recursion is my favorite part in this course so far because it is easy and interesting, but now, I changed my mind after using recursion in a tree and linked list, etc. Recursion is one of the most difficult parts to learn in this course. I have to say, using recursion in our code really helps a lot and looks simple and clear. It is much better than writing whole bunch of codes that is awkward for people to see. However, every time I'm asked to write a code with recursion, I feel like confused and have to spend a lot of time working on it. However, the good thing is that in assignment 3, I can figure out how to write a grow function using recursion by myself. It suddenly brings me confidence and encourages me to study more on recursion. Hopefully, by the time the final exam comes, I'm not afraid of recursion any more.
compared with this slog http://148slogger.blogspot.ca/, I find that we have the same problem and it is not only me that have a problem on recursion. The key part of recursion is to figure out the base case and the body. So, just like the instructor says, every time you write a recursive code,work from the base case up, and then test your base case. Once you are sure it works, test a problem one step larger. Practice more on recursion with this method and I'm sure it can be solved easily.

Sunday, 22 March 2015

week #10: impressions of week 9

Last week, we just finished test 2, and again, I feel regretful on how I prepare for the test. I remember that when I was preparing for the first test, it was so confused to me because which way will the instructor test on and what the difficulty it is. Therefore, what I did for test 1 is to look over the lecture in slides and do past test. I didn't focus too much on lab exercise at that time, which, surprisingly, gave me a pretty good mark. However, after I looked over my test, I was like I should have done more on lab exercise and my mark could be even higher. However, this time when I was preparing for the second test, I totally forgot about that, and again, I started reviewing the test by looking over the slides and then past tests, which is exactly the way I was using in the first test. How stupid I am to have the same mistake twice. I can tell that the grade of my second test will not be as good as my first test this time. Re-doing the lab exercise is really helpful not only for preparing for tests but also for applying the new knowledge which was taught in lecture into real problems. Due to the lab, I am able to understand the course. For me, I can't make the same mistake three times. For my final exam, the first thing to do is to re_do the lab exercise based on what we've learned.
Also, unlike the last week in which we learned about how to mutate the linked list, this week, we came into a harder lever, which is to mutate the BTNode by writing insert and delete functions along with the step of algorithm, which pretty helpful.


Sunday, 15 March 2015

week #9: impressions of week 8.

This week, we learned about the linked list. It can be seen as a sequence of nodes, each has a value and a reference to next node. When I first saw it, it think it is just like the tree writhing in a horizontal way. However, there is much difference compared with a tree. For instance, linked list is a wrapper class of LLNode which represent a single node, but there is no wrapper class for a BTNode. Also, an empty linked list is an instance of the class, with attribute values set to show it’s empty, while an empty tree is represented as None.
Although, we've looked over the codes in linked list class and learned how it works, I'm still confused about it because it is not in way i used to think. The first thing we learned about is to traverse a linked list, which has a pattern that is pretty helpful:
And the most important part in the linked list is how to mutate a linked structure. It is easy to understand how it changes through the code if we draw a simple diagram, which shows both the front and the back and the current node and previous node. Like this:
Basically, those are what we learnt about linked list. If we look at the code of a linked list, it is very simple and sometimes it is simple enough that I am not sure how it can work through python. Every time I try to write a code like this , I always think in a difficult way and as a result, the code I write keeps failing. In order to get over it, I find that do lab exercise including the extra practice in the back every week is a good way to learn how to use it properly.

Sunday, 8 March 2015

week #8 : impressions of week 7

In week #7, we continue learning tree. Instead of general tree which is the new knowledge taught in week #6, we learn a particular kind of tree called binary tree as well as the node class for a binary tree. A binary tree is a tree which only has two children called left children and right children. The binary tree can be easily understood once we got the idea how a general tree works. However, some functions under a binary tree class including contain function is a little bit different from the general tree class as we have to make it more specific into left and right children rather than just children.
Here is the contain function in a tree class:

And here are the contain functions in a binary tree:

All of them use recursion: first assume that the function contains works, and then make it to a helper function into the code itself. The only different is that writing contains function of a binary tree, we have to think both left and right children not like that in a tree class.
Overall, I think the tree class is interesting and is pretty helpful for us along with the recursion. Once we understand them and know how to use them perfectly, it will be our treasure in future studies.


Sunday, 1 March 2015

Summary of recursion

For the last few weeks, we have learnt recursion including how to understand the recursion code by tracing it and how to write some easy codes with recursion. But more importantly, in order to fully understand the what is the recursion, we need to define how to think in a recursive way.
For tracing the recursion code, I think it is the easiest part in the study of recursion. Just plug some examples which is from easy to hard into the code step by step and finally we will get the correct result unless we are not carefully enough.
For writing the recursion codes, it is a further lever of studying the recursion. Here is the way it goes, the problem with recursion can be easily solved and will be straightforward if you get used to recursive thinking. However, you can't even write a word on it if you are not familiar with the recursive thinking. So, a recursive way of thinking is very necessary for us to learn the recursion. 
So how to think like that? It is kind of different from when we do a normal code. Unlike we try to figure out the necessary code that can return the result we want when we are writing the code without recursion, we need to get the idea that what does the whole function do and think in a opposite way, which is that we assume that we've already got that function and use it as a helper function into the code. Before using that, we need to find a base case, which is the easiest possible result that it might return.
For me, although I got the idea how the recursion works, I still need more practice on that. I did the lab about recursion with some easy exercise and I got them all right. But the fact is that the recursion is weigh much harder than what we did before as we've started learning the tree which has almost every function that has to be done using recursion. I hope I can get used to that. 

Monday, 16 February 2015

summary of Object-Oriented Programming concepts

Talking about Object_Oriented Programming, I would like to say that almost everything, such as objects and classes, that we have learned though this course except recursion helps us understand  the Object_Oriented Programming well, which is short for 'OOP'. OOP is the way of programming in order to design the application more focusing on using objects rather than logic. In Object_Oriented Programming, we don't care much about how the logic goes between input and output, what we mainly care about is the objects that were mentioned in this application.
I remembered that at the beginning of this course, we were learned abstract data types (ADTs) in python including classes, attributes, methods, etc. According to the course notes,  "an ADT speci es the intended meaning of the data it stores, and the operations it provides on that data". The stack is an typical example explaining what we basically do with ADTs  with some general features of ADTs. A stack, obviously is the object and pop, push and is_empty are methods used to manipulate the stack. Also in our first assignment, we use OOP concepts  to make a game with five classes. Our first step is always to find out objects and operations needed by this object.
Inheritance is also a concept which is important and beneficial to understand OOP. Sometimes, we only have general features which does not satisfy some specific requirements. Employee, as an example that was taught in class, is the general object ( parent class). However, we have different kinds of employees under that parent class like hourly employee and salaried employee, which are named child classes used to implement the parent class. As a result, hourly employee and salaried employee share the same features as employee but have their own attributes on the other hand. This method is so helpful so that we don't need to overwrite the same code under a class.
In a conclusion, understanding Object_Oriented Programming concepts is pretty important to us because it is the basic stuff we need to know in order to make a further move into computer science. After I summarize the OOP concepts by looking over the whole thing from the course notes, I feel like this part of knowledge is much clearer to me. If we have something not familiar with, reading course notes over and over again might be a good way to get through.