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.
Sunday, 23 February 2014
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 ! :)
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.
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.
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.
Subscribe to:
Posts (Atom)