Monday, 8 February 2016

CSC 148 Python Week 4 Slog: Stack and Sack

This week, we learnt two new abstract data types: stack and sack. A stack contains items of various sorts. New items are usually added on to the top of the stack, items may only be removed from the top of the stack. It’s a LIFO (last in first out) structure. However, sack is different from stack. New items are added on to a random place in the sack, so the order items are removed from the sack is completely unpredictable. 

From my perspective, I find stack a little bit hard to understand. I then use a stack of books as an example of stack in python to help better understand the concepts. Because when we have a stack of books, we add the new book to the top of the old books but remove the most recent added books first. So it is a last in first out order. Also, the order of the books in the stack is important. Here, from this graph, we can know more about the structure of stack using "push" and "pop":




This concept is different from a queue concept which is first in first out as the people waiting the first in the queue should be removed first. This algorithm of stack can also be used in different places like matching brackets in sentences. From this class, I learnt that linking abstract concepts to real world applications is a good way to learn new concepts.




Thursday, 28 January 2016

CSC 148 Python Week 3 Slog: Start from the very begining


Python is a widely used programming language, which starts to become popular in recent years. As a fourth year Statistics and Geography student, I have not done anything related to python since my second year. But I still continue to use programming knowledge in different languages like R for Statistics and Javascript for Web Mapping. I always want to pick up my python programming knowledge and thus I take this course to deepen my understanding and practice of python. Since this is my last year of undergraduate study, I am excited to take this course and hope to learn more about python.

My first impression of the course is that I need to work hard and spend a lot to time practice coding. As I took CSC 108 2 years ago, I find it hard to catch up with the professor and other students although I used other programming languages and reviewed the previous 108 knowledges during the rampup session. This course mainly introduces program design principles and techniques as well as how to program efficiently. Till Week 3, we learnt and practiced how to build classes and I learnt the principle to code "class" and the logic behind it. From my understanding, class is an abstract data type that models a group of objects based on their common attributes and actions. Thus, a frequent noun may be a good candidate for class, its properties may be its attributes and the actions may be its methods. Other than this, I also learnt the importance of doing good documentation so that other coworkers can also understand my work and we have to keep this good habits. I sometimes find it easy to understand code but difficult to implement and thus I will spend more time in the future writing down the codes. 

So far, I find it really interesting and want to learn more about python. In the following weeks I will keep writing blogs every week about the topics that I learn and write my learning reflection. In my last blog, I will also write my reflection on my previous blogs to see whether my view change or not. I hope by the end of the course I can have deeper understanding about python.