2014年2月2日星期日

Recursion

As the day gone, the course goes further and deeper. We studied how to use unittest on lab,by the way, it was extremely useful for me to solve the CSC108 unittest formation problem, and the recursion problems with turtle model last week. From the study and the exercise, I comments some reasons of using recursion to handle problem. Firstly, the length of programming code with recursion would be less and shorter than with for or while statements,the old methods. Secondly, it is more flexible than those two statements, because those two statements have the specific formation, whereas, recursion calling itself again and again to hit the target is easy to modify and transform. The third one is to change the difficult problems to the simple-solving problem. Taking our A1, the tower of hanoi, for example. The algorithm of the game seems to be difficult to tackle if using for or while statements. However, after several times of tracing the steps, it is just unimaginable easy method when selecting recursion. However, it is said that the sword has the two sides. if want to use recursion, the method or the algorithm should be very clean. Sometimes, one easy recursion would be spent much more time on finding what it is and how to write the code by tracing. I am still struggling for the A1. Most parts (approximately 70%) have been done.

没有评论:

发表评论