Friday, April 3, 2015

Week12-Final Thoughts about CSC148

This week is last week of the semester, can't believe that I finally completed all the works!  I decide to write some final thoughts about the course, and go over what I have done in these months. 

The first couple weeks of this course is about basic ideas of object-oriented programming and abstract data type. They are developed based on what we learnt in CSC108, and I consider them to be quite straight forward and easy to understand. I met my partners for Assignment1, who are also my team mates for Assignment 2 and 3 in later part of the term. We completed Assignment1 together and received a pleasant grade. 
Test 1 is a critical time spot in this course because everything after test1 started to get complicated. When the topic of Tree is introduced, we have to develop a kind of recursive thinking, and  look at each problem in a bigger picture to solve them. After Assignment2, the course speeded up to dramatically. If you fail to understand the basic idea of Tree, you won't be able to get Binary Tree, than you will fail LinkedList and NNode. I have to study so hard to make sure that I am not behind for the next lecture.Then, the strike came. I was quite happy that TAs can unite together and fight for a better pay. However, I couldn't meet my lab partners because the labs are cancelled. The last couple weeks are not very challenging. My partners and I managed to finished Assignment3 on time, and ever things went well. 

Overall, I won't rate this course as enjoyable, because I did find quite a few difficulties throughout the term, and it took me much more time comparing my other courses. However, I definitely feel proud of myself for completing this course because I finished all the required tests and assignments that I never thought that I would able to complete as a psychology students with absolutely no computer background. I will carefully prepare for the final exam, and I hope I will have good luck on that day. 


Friday, March 27, 2015

Week11- Thoughts on Test 2

Marks for Test 2 are finally out! Therefore, I decide to write down some thoughts about the test. Even though the score is not high, I have to admit that the test wasn’t as difficult as I supposed, and in fact, it was an interesting one.   I really like the idea of the first question, since we were asked to draw our algorithm out, and this is much easier than the following questions, which require us to write the code.

I was able to answer each question, however, I am not sure whether my code is accurate and can run. I have some difficulty with the last question, and I think it is because I don’t understand NNode very well comparing to LinkedList and Binary node. Overall, I think it is a fair exam, since the last two questions are very similar to our lab questions, and we all have an entire reading weak for preparation. My mark isn’t very nice, but is not that disappointing as well.

Another thing that made me worried is the strike. All labs are cancelled due to the strike. However, our test questions are often very close to lab questions. I think I will ask my assignment partners for help, and see we can finish all the labs together. This will be a good preparation for the final exam.



Friday, March 20, 2015

Week10-Thoughts on Code Efficiency


A crucial idea that I learnt in this course is the importance of efficiency. 

The idea of algorithmic efficiency wasn’t this important in CSC108 when we were mostly dealing with lists with defined length. However, efficiency becomes so important now because it is one of the key elements that ensures high performance of a complex code since it determines the the speed of runtime execution for the code. There are different ways to achieve efficiency, for example, one can reduce the number of functions, and use recursive functions instead of writing a bunch of loop. No matter how, the goal of code efficiency is to reduce resource consumption and  runtime as much as possible.

Today, I also read my old writing in Week5 which is about recursion, and realized that I have a different understanding about the topic now. In my old post, I said that recursion is similar to while loop and for loop, because they are all about repeating calculation. However, I realize that they are very much different in the sense of efficiency. The following code aims to determine whether a sorted list contain a specific number v. It is very efficient because it employs recession. Every time it runs, it divides the list in half, and search the two parts separately at the same time.  This function can also be written by while loop, but will look much longer and take more time to execute. 

class SortedList(list):
    ''' list in non-decreasing order '''

    def __contains__(self, v, start=None, stop=None):
        ''' (SortedList) -> bool
        Return whether SortedList (self) contains v.
        '''
        if start is None:
            start, stop = 0, len(self) - 1
        if start > stop:
            return False
        elif start == stop:
            return self[start] == v
        else:
            mid = (stop + start) // 2
            if self[mid] < v:
                return self.__contains__(v, mid + 1, stop)
            else:
                return self.__contains__(v, start, mid)

Friday, March 13, 2015

Week9-Review on Stack and Queue

I just realized that more than half of the term is completed!!! Among all the topics we covered, I consider Stack and Queue to be the two easiest one for me.  I love this topic because every step of only does one job. It is different from other topics such as recession which we need to complete repeated calculation for one single method. Even though Queue works according to the rule of 'first in first out' and Stack is 'first in last out', there is a great similarity between the fundamental steps of building a Queue and Stack. I am going to decompose the basic steps of a typical Stack and Queue class in this blog. 


So, for the first step, we initialize a Stack or Queue to be empty.










 The second step is to add an object the end of the Stack or Queue

After all objects are added, we can remove them one by one. For Stack, we always remove the last object, and for Queue, we remove the first one.   



 



 

Finally, we ask ourselves whether all the objects are removed from the Stack and Queue. This step is the same for both classes.



 



















Tuesday, March 3, 2015

Week8-Thoughts on Test1


Couple weeks have passed after Test, but I decide to write down some thoughts about it for future reference. I was quite nervous about it, so I copied all the lecture slides onto the cheat sheet. However, I realized that it is completely unnecessary, because I don't really have time to double check my answers according to the original code on my messy cheat sheet. I think I need to record some insights so that I can have some clues for future test preparation. 
1. Review lab materials.  The last two questions is very similar to lab questions.
2. Review a code my re-typing it. Since CSC108, I have known that there is a difference between understanding a code and being able to reproduce it during the test. I often have problem with generating a specific code even though I feel that I have the general understanding of the algorithm. 
3. Use the cheat sheet efficiently. It is unnecessary to have a fill every corner of the paper, having the sheet means to providing me insights for complex problems and confidence for simple ones.
4. Review Assignments. Submitting an assignment does not means to say goodbye to it. Many classical algorithms are repetitive, and can show again on the test. 
5. Read other people's slog. I check my friend Sylvia's slog(http://sylviasuyao.blogspot.ca/) quite often because I know that she has a great overall understanding of the course. When I had difficulty of understanding recursion couple weeks ago, her writing about recursion, especially the article "Recursion Explain with the Flood Fill Algorithm" she linked in her slog helped me a lot. 
All in all, this test wasn’t too difficult. I think the grade should not be disappointing, and I hope that I can apply what I learnt in this test to future tests and assignments. 

Friday, February 27, 2015

Week7-Thoughts on Abstract Data Type

Abstract Data Type (ADT) is an abstract data type is a model for a particular data structure defined by the methods it can perform. It can be implanted into not only python, but also other programming languages such as java and C++. We learnt three kinds of ADT in CSC148, and I want to introduce them separately.

The most basic form of ADT is stack. Stack allows us to add new items to the top of the stack, then, items are removed from top to bottom. In other works, items are added and deleted based on the rule of “last-in-first-out”. A stack involved three basic operations: push() enables new data to be added, pop() removes the top item, and isEmpty() determines whether everything is removed. The second kind of ADT we learnt is Queue. It is very similar to Stack, but its first added element is removed first. Similarly, A Queue also involved three basic operations: enqueue() enables new data to be added, dequeue() removes the bottom item, and isEmpty() determines whether everything is removed. The third ADT I learned is tree. Like stack and queue, tree also stores data. However, Tree stores data in a hierarchical order. Item in a tree is called node, and bottom nodes that branch out top nodes are children of the top nodes. And nodes without any children(are not parents) are referred as leaves. And finally, the node that the very top is called root.

Tree is the most difficult Abstract Data Type among the three. I also think that it is the key to solve the following assignment, because there are so many variations that can be developed based on it.


Thursday, February 19, 2015

Week6-Object-Oriented Programming

Object-oriented programming is a method that represent real life systems and aims to solve real life problems. The name of Object-Oriented Programming is pretty self-explanatory. OOP is a type of programming that revolves around devising procedures by using a variety of independent and co-ordination objects. It also involves concepts such as class, objects, inheritance, instance, instantiation, message passing as so on.

Python is a classical Object-Oriented Programming language. What are objects In Python? They can be Python built-in data types, such as strings, boolean, and list.  They can also be “classes” that are created by programmers. Class can also contains various “methods” that perform corresponding jobs. Moreover, we can create subclasses that inherit the characteristics of the superclass and perform different jobs by adding methods.  For example, we can create a class called “food” which is defined by the eatable characteristic. This means that subclasses of “food” such as “fruit”, “meat” and “vegetable” all shares the characteristic of being eatable. 


In the lecture, Prof. Heap created a parent class called 'Shape', and two classes of 'Square' and 'Triangle' which inherit the variables of 'a' and 'b' from the 'Shape' class. One thing that I find important here is that the parent class raise an error when it is called to perform a function of its children.  
 def get_area(self):
        ''' (Shape) -> float

        Return the area of self.

        >>> from square import Square
        >>> Square(0, 0, 10).get_area()
        100.0
        '''
        raise NotImplementedError('Need a subclass')

This is my basic understanding about what Object-oriented programming is. My classmate Christian has a deep understanding about the topic. Her writing of 'Week 6 Object-oriented programming concepts'(http://christiangarciacsc148.blogspot.ca/2015/02/object-oriented-programming.html) and 'Week 4 Classes and Subclasses'(http://christiangarciacsc148.blogspot.ca/2015/02/csc148-week-4-classes-and-subclasses.html) helped me a lot in understanding basic ideas of  
Object-oriented programming  as well as the purpose of this course.