Wednesday, February 24, 2016

Week 7

The main programming languages we study in CSC148 is Object-oriented programming. Object-oriented programming is a programming paradigm that makes the functionality and data together into an object, and python is an object-oriented programming languages. The objet-oritented programming in python consists of two parts: classes and methods.The class is a user-defined in the class. The class has an __init__(initialize) method which is used to set up attributes and new instances. I think Object-oriented programming provides a very clear modular structure, and easy to modify when there is only a slight change to the existing code. Overall, it is clear structured and intelligible.
I consider recursion as the hardest topic I have encountered in this course so far. To use recursion, we should divide the problem into some sub problems, and solving the problems by calling the sub problems. The recursion really makes some complex questions easier, and its really hard to come up with the idea in the first place. The recursion requires a case outside it to make itself finite.

Week 6

This week, we focused heavily on the use and effectiveness on recursion. I certainly have heard of this technique in solving problems before but never really wrapped my head around it until now (although I would say that I am still pretty bad at it). Recursion is definitely very powerful technique if used correctly at the right situations but honestly, simple iterations should be used whenever possible (not over thinking a problem). I was realizing this because as we learned in the first few weeks of class, every single time a method is called, it is put onto a stack and as a result, takes up more memory. In the case of constant recursive calls, it makes a lot of sense that it would create an immense amount of overhead to execute its codes. It would be sensible to avoid recursion as much as possible.

Wednesday, February 10, 2016

Week 5

We focused on a data structure called linked list this week. It is very queue to a stack except each object inside the data structure holds the reference to the next object. However, it is comparatively much more superior to a queue in terms of efficiency because insertion of new elements mean only having to deal one reference (as opposed to moving items back and forth in a queue). The lab was very challenging this week because we had to literally code to find the length of the linked list and how to insert a new element to a desired position without raising any errors. I realized I over think many parts of the code and it definitely consumed a lot of time (tried to use recursion every where I could). Sometimes, it is better to think from a more simpler perspective and it could turn out to be a lot more.