Tuesday, April 7, 2015

Last impression.

How time flies! The first slog is still in my mind. And now I am writing the very last slog for this course. The final exams are coming and so is stress. However, it is still necessary to take some time to write this last impression for csc148.

    Compared with csc108, which I took last semester, csc148 is much more challenging. I think, what we have went through in this course can be summed up by one word, recursion. ‘Recursion’ is a simple word but one of the most powerful tools in computer science. From tracing recursion to implementing recursion, we need tons of practice. Practice makes perfect!
   
    First, I would like to thank to Mr. Heap for his fantastic job as my instructor. As we know, due to the strike, we lost a lot of support comparing what we deserved. Instructors offered us more office hours to decrease the loss as much as possible. I really enjoy the each single lecture and the process to work out assignments. Though I had some hard time to deal with some of questions in assignments.

   Talking about the three assignments, they are the most difficult tasks I have ever had. Sometimes I was so close to giving up but I made it finally. They are interesting and I can get a great sense of accomplishment whenever I implement a function successfully.

    In terms of the two term tests, I get satisfactory grades for both of them. But I know that the final exam will be much more tough than term tests. I am preparing for the final exam and trying to get a grade as good as possible.


    Hopefully, I will continue to take CS courses next semester. I would like still chose Heap as my instructor.

Revisit earlier SLOGS

It is nearly the end of this semester. The topic of slog for this week is revisiting the earlier slogs, form the very beginning to the very last one. In the first slog, I illustrated why geeks should write. Until now, I still agree the idea that writing is a vital part of geek’s work. And that's why we keep writing slog every week. In the second slog, I said that this course is not that difficult as I expected. Now, I found I was completely wrong. Converse to my original view, I found this course is even much tougher than I expected. Compared with csc108, csc148 is very challenging. In addition, the majority of the challenge is recursion, of course. From tracing the recursion to implementing recursion, we need a deep understanding of each function’s description, including what they are supposed to do. Besides, we learnt numerous date structures, such as binary tree, linked list. They are all based on recursion. They are all difficult as well as interesting. I enjoy the process to explore them.


        On the other hand, the assignments also leave me big impressions. When I first tried to do assignment 1, I felt that was so hard that I had no any idea. However, now, I realize that the assignment 1 is the easiest one among the three assignments. Though I struggled in every assignment, I work them out finally. These hard works not only enhance my skills relating computer science, but also teach me to persist.

Impression of week 9

Last week we had the term test 2. To be honest, before the test I was nervous and worried. Due to the fact that I would be dead if it asks us to implement recursion functions that we never saw before. Before the test, I mainly reviewed the class binary tree. In addition, I prepared an aid sheet in case I forget something during the test. I have to admit for some functions, I memorized them instead of understanding them. I felt overwhelmed when I try to understand each recursion function.

       Fortunately, when I got test paper, I felt relieved because some of them are mostly as same as the questions from the lab. However, I still got trapped with the postorder. I have to say that Professor. Heap got me! Because the inorder, postorder and preorder are exactly my weak points!


      Anyway, I have confidence about getting a good grade in this term test whereas I found many defects as well. So for the coming final exam, I need to work harder, especially on implementing recursion functions.

Friday, April 3, 2015

Impressions of Binary Trees #Week 8

In week 7, we were introduced Binary Trees. Binary Trees structure is very popular and is being used wisely. 
It is easy to see that this is a recursion. Therefore, understanding well is significant for understanding Binary Tree.

There are three orders for traversing a Binary Tree.
1. Inorder: left child, root, right child
2. Preorder: root, left child, right child
3. Postorder: left child, right child, node




Tuesday, March 3, 2015

My impression of first few weeks #Week 4

Well, my impression of the beginning of the class is only one word- tough. Firstly, the speech of the professor is a little bit fast than those professors who I met before. As an non-native English speaker, adapting the fast speech would be a huge work for me. At the first time, I missed many information about the lectures, therefore, this is one of the reasons that I felt tough. Fortunately, it became much better. Secondly, in this course, there are no more basic concepts of python should be taught. As a result, many of new python methods that we should be able to figure out by ourselves. In addition, many new concepts , such as Abstract Data Type, OOP, etc, that I have never been met before. Thus, this is one of the reasons as well. Finally, we also have to learn how to write well in this course. Basically, as a computer science student, writing is one of my weakness, therefore, learning how to write well is a big problem for me as well. Hopefully, I can do this course well. :)

Saturday, February 28, 2015

The summary of Object-Oriented Programming #Week6 (to be graded)

In the csc148 class, we learned a new method of programming, which is Object-Oriented Programming (OOP). At the beginning of the class, I was struggling in the Object-Oriented Programming because it is a new concept and I had totally no idea what it is. Fortunately, a couple of weeks later, I made sense about the Object-Oriented Programming.

BASIC CONCEPTS ABOUT OOP

There are some concepts about object-oriented-programming:

What Is an Object?
An object is a software bundle of related state and behavior. Software objects are often used to model the real-world objects that you find in everyday life. This lesson explains how state and behavior are represented within an object, introduces the concept of data encapsulation, and explains the benefits of designing your software in this manner.
What Is a Class?
A class is a blueprint or prototype from which objects are created. This section defines a class that models the state and behavior of a real-world object. It intentionally focuses on the basics, showing how even a simple class can cleanly model state and behavior.
What Is Inheritance?
Inheritance provides a powerful and natural mechanism for organizing and structuring your software. This section explains how classes inherit state and behavior from their superclasses, and explains how to derive one class from another using the simple syntax provided by the python programming language.
What Is an Interface?
An interface is a contract between a class and the outside world. When a class implements an interface, it promises to provide the behavior published by that interface. This section defines a simple interface and explains the necessary changes for any class that implements it.


A SIMPLE EXAMPLE ABOUT OOP:
For example, we are trying to make a small RPG game. So how do we start it?
Well, there are some monsters and heroes in this small game. They can attack each other with different skills (try to compare this game with Pokémon).


First of all, we need to create a class which called "Heroes" and each hero has the features of blood, age, and name. In addition, do not forget create a class of monsters.

Here's the code:




Well, now we have finished creating classes, it’s time to create some objects.

hero1 = Heroes(100, 20, 'Lee', 'Fire')

The hero called Lee, he has 100 blood, and he is 20 years old, and he can use fire


monster1 = Monsters(50, ‘Snoopy’, ‘Bite’)

The monster called Snoopy, he has 50 blood, and he can bite someone.

Image if you want to create thousands of monsters and heroes in the game and if you do not know how to use object-oriented-programming, that will be very tough for creating the game. However, if you know how to use OOP well, you can make a flexible combination for each object and that will save your time.


CONCLUSION:


Object-oriented-programming is significant and useful for programmers especially for creating the Role Play Games and there are several reasons, which are easy to maintain, easy to extend, efficient. Firstly, the idea of using OOP has a higher readability because of the existence of the inheritance. Even though the requirements need to be changed, the maintaining can be only working with local models. Therefore, it is convenient and low-cost to maintain a program if we use the concept of OOP. Secondly, because of the features of inheritance, encapsulation, and polymorphism, we can design naturally out a well-structured computer system with high cohesion and low coupling. Finally, when we write code, we can create abstractions of objects from the real world according from our demands. Using this concept for addressing programming problems is close to our daily life and the natural thinking, therefore, there is no doubt that it can enhance the quality of code and the efficiency.





Wednesday, February 25, 2015

THE AMAZING RECURSION #Week 5

RECURSION IN DAILY LIFE

It was my first time learning how to use recursion in programming in week #4.  But it was not the first time that I come into contact with recursion. I remembered when I was a child, sometimes I thought that the god (god A) knows my thoughts, and an another god (god B) knows that the god (god A) knows my thoughts, etc.
We can see there are many recursion examples in our daily life. For example:


Therefore, recursion is not only interesting and also is not mysterious.

WHY PROGRAMMERS NEED TO KNOW ABOUT RECURSION

Well, it's said that an ordinary programmer like using iteration, however, a talented programmer like using recursion. Even it is just a joke, but recursion is significant for a programmer. Knowing how to use recursion can let your code run more efficiently, and since most of the programs are a teamwork, therefore, reducing the amount of codes is also important for a good programmer.
Here is the comparison between iteration and recursion:
==========================================
Iteration:
def factorial(number):
product = 1
for i in range(number):
product = product * ( i + 1 )
return product

Recursion:
def factorial(number):
if number <= 1:
return 1
else:
return number * factorial(number - 1)

===========================================
Basically, the code of recursion looks simpler than the code of iteration. Image if you are working with a group and your teammates have to read your code. It's important that keep your code as simple as possible.

WHAT IS RECURSION?

Here is the definition of recursion from WIKIPEDIA
In mathematics and computer science, a class of objects or methods exhibit recursive behavior when they can be defined by two properties:
  1. A simple base case (or cases)
  1. A set of rules that reduce all other cases toward the base case
For example, the following is a recursive definition of a person's ancestors:
  • The ancestors of one's ancestors are also one's ancestors (recursion step).
The Fibonacci sequence is a classic example of recursion:
\text{Fib}(0)=0\text{ as base case 1,}
\text{Fib}(1)=1\text{ as base case 2,}
\text{For all integers }n>1,~\text{ Fib}(n):=\text{Fib}(n-1) + \text{Fib}(n-2).
Many mathematical axioms are based upon recursive rules. For example, the formal definition of the natural numbers by the Peano axioms can be described as: 0 is a natural number, and each natural number has a successor, which is also a natural number. By this base case and recursive rule, one can generate the set of all natural numbers.
Recursively defined mathematical objects include functions, sets, and especially fractals.
There are various more tongue-in-cheek "definitions" of recursion; see recursive humor. 

THE DIFFERENCE BETWEEN RECURSION AND ITERATION

An iterative algorithm is based on a repetition of a set of instructions (block) using a loop construct of the programming language. However, a recursive algorithm repeats the code by calling itself. The main advantage of recursive algorithms is their compactness and understandability. Their disadvantage is a need of additional system resources to maintain the call stack.

CONCLUSION:

Personally, although using recursion can reduce the amount of codes, however, something it might cause a serious bug if we use recursion casually because it would cause recursion depth goes infinity and it will take up the whole memory.