Sunday, 15 February 2015

Week 6

Week 6

'Class' is the most important blueprint in object-oriented programming. Class logically groups related functions together to create an object. The __init__,  __str__, __repr__,..., etc. method which defines the class and initialize the class. The subclass which I found is very convenient as it inherit the characteristics from it's base class and add additional functions to approach make the 'object' behave in a certain way. The subclass shows the characteristics of 'lazy geeks' or smart geeks perfectly. 

This week's lab was confusing. I have looked at the lab briefly before tutorials, and I thought we just need to complete three functions. However, the three functions was getting harder and harder. I realize that I need more practice and become more familiar with 'trees' and 'recursion'. Thinking back about the slides and definition of trees, it actually make more sense to me every time. I must remember to keep up with the materials we learn each week as the material gets more harder. 

Week 5

Week 5

Recursion saves a lot of work for computer scientists, it's a function calls itself. We did some exercises on input and output numbers using recursion. The very basic example nested list illustrated how recursion works in a simple and elegant way. I feel that recursion is a very interesting and convenient tool compare with iteration. However, tracing recursion was a bit confusing. We must trace the function calls in order, just like trying to understand how a computer thinks when calling recursion, step by step. For example:

  1. Trace nd([5, [[1, [2, 3], [4]]]])
         nd([5, [[1, [2, 3], [4]]]])
         --> 1 + max([nd(x) for x in [5, [[1, [2, 3], [4]]], ’ox’]])
         --> 1 + max([0, 3, 0]) --> 1 + 3 --> 4
    
This was an example we did in lab. The funny thing is I always have the impulsion to just sum up all the integers in the bracket. It's kind of ridiculous, but I think it's because I'm not use to recursive functions and concatenate the sub calls of the function itself. 
    
Practice. Exercise.

Sunday, 1 February 2015

Week 4

Week 4

This week was a tough week for me. I had two CS assignments due around the same time and all of them takes time to do. The first csc148 assignment was to design a game called 'SubtractSquare'. After I read the handout I feel that none of it make sense to me and I don't think I can ever design something like that. It makes me feel scared to even start the coding. However, after talking with classmates and friends I felt more confident. I totally forgot that I could partner up with someone and work it through together. This process was not smooth as I thought. I was abondoned by two person, one dropped the course, and the other one had to join another group. Luckily, I found someone at the end, although we weren't good at coding, but we tried our best. I think it must be a lesson for me to learn, and I will definitely start the assignment earlier with a partner next time. This way I will have more than enough time to complete the assignment.

This weeks lab was about recursion. I enjoy the lab every week because it gives me the opportunity to exercise and ask questions. Since I have start this course I feel that there is a connection missing between 108 and 148. Maybe it was the view lecture that's missing or the online PCRS that was missing. However, this week's lab exercise seems very familiar to me. I must do more exercise now. Next week is the real tough week since I have three test and two of them are on the same day. I must manage my time and study hard!