Sunday, March 1, 2015

Week 7 Summary of Recursion

I've learned and are using both 'For' loops and 'While' loops in some functions to solve several problems that have finite steps. However, it's hard to design functions which have infinite steps and it is also hard for us to make an accurate extimation on how many steps the functions would proceed. The professor introduced us a much easier way to simplify complex functions from a huge size to a delicate structure which make uses understand easily and make computer run programs much faster. That's recursion.

As what I wrote in slog of last week, "when a function calls itself, we say that is a recursive.", which means this function use recursion strategy in itself.

At the beginning of the lecture of recursion, we've learned how to understand recursive data structure. A recursive data stracure always contains some substrures and itself.


Adding the statement into the functions which make functions call themselves calls recursive call. A feasible recursive call contains a base case and other cases and also a case make function recall itself. It's significantly important to built a base case in funtion. Because missing a basic case, which is similar as setting conditions for 'while' loops,will result in infinite loops of functions.

In recent lectures, I've learned how to use recursion in real problems such as Tree classes.

Recursion is a good strategy to solve problems like class Tree. When we are facing problems like "subitems contain subitems contain subitems....."(this is a recursive data structure), we use recursion which is based on a solid base case to recall infinite times of problems themselves untill we operate whole possible processes in structure.

What I think is a challenge for me is how to determine a correct and precise position to put my recursion. It's easily for my to forget put recursion in function and put correct recursion in 'return'. What should I do in future to overcome these challenge is to do more extra exercise so that I can master this strategy more easily.

No comments:

Post a Comment