2014年3月30日星期日

SLOG: recursion

Recursion recently becomes our new topic after the learning of basic idea of OOP. It can be briefly described as a progress that function repeatedly runs itself until it reaches some sorts of conditions or goals, otherwise, it would keep looping. It is somehow similar to the ideal of using ‘while loop’, but in this case, it put the function itself back into the code, which increases a lot of challenges and deficiencies.  Binary tree would be a great example to show the use of recursion. Since it needs a majority of times of looping to get answer, recursion becomes amazingly suitable to binary tree search. I remembered the time when teacher show how the recursion works and use it to draw out the picture, and it was shocked and amazing.


An achievement that we got in this week was that we finished the assignment one, the one that needed to automatically find the running times of Tower of Haoni. But instead, we used cheese this time. To be frank, it is so difficult to use recursion cause it required a lot of thinking while using it, even though it needs only single-one line code in a function. Those people who did not learn computer science before would feel unconfident to use recursion.

没有评论:

发表评论