2015年2月8日星期日

week5

I learnt tracing recursion recently. This is one of most interesting function that I’ve ever seen since I began to learn python. Briefly, it is a function that repeat itself inside the function. Perhaps, you still do not have a clear idea. Actually, we can assume that there is a function called “opening doors”.

The purpose of the function is to open a door whenever you see a door. Then, I go to a random hotel. There are many doors on each floor. Next, I see Rm 101 with closed door. Based on the “opening doors” function, I ought to open the door. Well, I see another door of bathroom and I open it again due to the function. Now, there is no more closed doors in the bathroom. So, I go out. And now I see a door of bedroom and I open it like what I did to the bathroom previously. Then, I see a door of balcony, open it. At present, I opened all doors in Rm101. So I go to Rm 102 and do everything over again and again until I open all doors of this hotel.  

Recursion function is like “this opening door function”. It will trace every same element within inputs.


In addition, I read over one of my classmate’s blog called http://sherryxq.blogspot.ca/. On her website, she clearly define some simple recursion function that we learnt during lecture. She also post some photos with notes. I think this helpful for us to understand a real recursion function. Even though someone wrote a list of list of list, appropriate recursion function is able to trace each level of it. 

没有评论:

发表评论