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