Sunday, March 29, 2015

Week 10: Revisit Week 5

   I revisit my week 5 SLOG that I talked about my first impression of recursion, which was not so good; I am glad that now I am comfortable understanding and writing recurssive functions. Like I pointed out before, it is essential to know how to trace a recurssive function before you can write one. And tracing is also a useful method to test whether the function you wrote works correctly.
   After a long period of time working along with recursion, I find that recursion is extremely efficient and can save us a noticable amount of time and lines for the problems that could break into parts. For example, as another SLOGer wrote, 6! could break into 6x5!, and then 6x5x4! and so on until it approaches to 1!; then we can use 1! as our base case recurse all the way until we get 6!. It is an really interesting example that gives me a clear mathematical comprehension of how recursion works.

No comments:

Post a Comment