Sunday 23 February 2014

week 7

REEEEEcursion :( haha joking i should be making a happy face -_- :')

sooo it took me a while and a lot of work to kinda grasp the idea of recursion... (i am still not very pro at implementing functions with recursion...)
But basically, it is, simply a function that would call on itself, until it reaches a base case. If the base case does not exist, then your function is going to run till your wing crashes.. or gives you an error, which you don't want.

It is rreeeeally useful because of it's "recalling" nature. The recursion-ception provides you a platform to go "deeper" into the function, all the way to the base case. -> Saves you a lot of codes ! We started learning LinkedList, and it is basically a tree... but only with ONE child :o Same as the tree, when you reach the last one, it is = nonexistence = None ! Pretty simple.


week6

AAANd i made the deadline for A1! :D Although i was not able to finish step 5 and 6.. because of poor time management, but i am glad that i finished it on time (kind of)
Treeees!

The terminologies set me off a little at first, but after listening to the explanation, i understood how a tree works.
A leaf must only have 1 parent (kinda weird cause parents are usually ... aNYWAYS), and there is a unique path from the root to each and every node/leaf. NO LOOPS!

Another trick to remember pre, post and in-order traversal is to trace the tree with your finger pointing right, left, and upward. I found tree a really interesting idea as it has a different "shape" from a list that looks like a line. 

Also, in the lab, we learned about two new functions : Filter and zip.
Filter eliminates all elements that are equal to False,
and Zip uses two lists and pairs each and every one, into a tuple. Then it gets append to its list. Hope it'll come in handy in the future ! :) 

Sunday 9 February 2014

week 5

In the lab this week, we further learned about recursion. I sorta learned it better (i guess..?) and kinda grasped the idea of recursion. You basically just have to make sure the "calling itself" function is inside the body, and has  a based case where it reaches and stops recalling. Pretty simple idea, but i always have difficulty learning it.. Room for improvements !

working on the assignment was a nightmare since i was working alone, and it was too much for a person .. i was stuck on one of the functions for the longest time (like move_cheeses), but after asking for help during the TA hours, i understood the complexity of recursion. 

Wednesday 5 February 2014

In this week of the lecture, we talked about recursion. To be honest I am still a bit confused about the format/idea of it, but through the labs and exercises that we've done, I am understanding it slowly - that it is basically it is the ability for the code to call itself. I found the drawing turtle super interesting and I am very fascinated by how much a simple code can do. I've learned that recursion is a very powerful format to simplify your codes in a few lines. One of the confusions i have right now is when to use recursion/for loops (at this stage they both seem pretty simialr to me.)

During the exercise, i further understood the use of exceptions and how to properly format my classes. It is very useful for computing since the other users of the computer might not know which part did they mess up.

Thursday 23 January 2014

     During the first week, I've learned that python uses object, which can store, process and transfer the information to other objects. Also, I have learned about how to apply my knowledge from CSC108 -  properly construct a class, into a more advanced level. For example, to have proper format of a class, the def functions should be indented and be within the "class".
     In the second week, I have learned about the differences between ADTs, and my knowledge based on ADTs have been enriched after the lab. I have noticed that stacks are in reverse order comparing to list, and sets cannot have duplicate elements within. These different characteristics help different situations in programming. For example, stacks are more convenient if we wanted to add objects from the "bottom" so the last object will always be "on top" etc.
     In the third week, the lab had helped me understand the concept of stacks better, as well as how to improve the efficiency of a program. The most interesting part of the lab was that I was able to write out a queue class and was able to learn the difference between that and sets/lists. Queue has a much much more powerful interface for programmers to use. For example you can set the maximum of a queue, and lists grow until you run out of memory.