Sunday, January 26, 2014

Week 4

Third week of class was over but i still feel like the class just started! May be because i have done any assignment projects yet as i normally learnt most by working through challenging problems in the assignments (at least in CSC108H1). 

The first assignment was posted on Friday and i will have about 3 weeks to complete it. I briefly read through the handout and noted that the theme of the assignment one is the Tower Of HaNoi. At first, i thought there would be something to do with Ha Noi's turtle tower, a famous tourist attraction in my hometown, Ha Noi Viet Nam. However, i was quiet upset to figure out that there is nothing to do with my home town, Tower Of HaNoi actually is a mathematical game, which, according to Wikipedia, has a "recursive" solution. So it was not too difficult to guess that there will be some recursive functions that i will have to code over the next few weeks.

As usual , we have a two hours lab each each. In my opinion, the tasks in the second lab were a lot easier than the first one that i told you in the last week blog. I and my partner worked all the way through the tasks fairly quickly and we got 30 minutes spares at the end for the efficiency problem. One of the possible solution was that for the dequeue function, instead of actually remove the element from the queue, we could use a variable that keep track of the position of the very first element in the queue. Every time, the function dequeue is called, the tracking variable is incremented by 1, thus the running time is reduced significantly. 

In the scale of 5, i give myself grade 4 for my own learning experience, class performance and effort in this week. 

Sunday, January 19, 2014

Extra#1 Recursion Limit

An interesting fact that i just knew ...

def max_recursion_call(number):
    print("The maximum number of recursive call is: ", number)
    try:
        max_recursion_call(number + 1)
    except:
        print("That's it")

By calling max_recursion_call(0), i figured out that the maximum number of recursive call can be made in Python is 979 times.

Week 3


It is just the third weeks of class after the winter break, but i am feeling a lot of pressure. The second week lab exercise was harder than i thought and struggled me and my partner for a while. I took CSC 108 last semester, we studied class and object but we did not have to write a full class, like the one in the lab exercise. And normally in CSC108, the questions told me exactly what should i do with the class (Eg: how many parameters  __init__ function should take, what methods should be included, ...). In CSC148, only the scenario is given and i have to look for noun, verb and adjective in the scenario then design the whole class's structure from them. It definitely was harder and took me sometime to adapt to.

I also learnt from the first week lab that i should do a detailed class design on paper first before starting any codes, especially when i have to deal a long and fairly complicated class like the one in the 1st lab. Otherwise, i just end up wasting a lot of time to rewrite the codes.

The homework exercise though is easier. I especially like the second question when i have to create 2 classes: Toy and Dog. I created a dog with my real dog's name as a parameter, and it is really funny when my dog created the sound "Yip! Squeak" when he played the toy, which i made for him (creating a toy object). And i guessed he really liked his toy, so i let him play the toy hundred times by setting n = 100. 

I really like the idea of the auto tester too, we have chance to see our mistakes and fix it before the deadline. I hope there will be the auto tester for next exercises.

On Wednesday, during the lecture, the class were introduced the idea of recursion. Although recursive function is not a new thing for many students, the recursive function used in the class was much more advanced than the one we studied in high school. I am looking forward to future lectures to see how much more complicated can it be!