In this week, we talked a lot about
recursions and trees. After one week’s of studying, I learnt that recursive
function is a kind of function that calls itself in its body. Recursion is
really efficient and useful, since it can solve problems easier and faster without
writing lots of unnecessary repeated codes, and therefore save the running time
and make the whole program more efficient. By using recursive function, we
break up the whole problem into smaller parts (usually the base case and the
general case which seems to have the same structure and therefore we can apply
the recursive process), and combining the solutions from each into a final
solution. However, I find out that it’s easy to make the function repeat
infinite times by writing the wrong recursive function, and sometimes I still
found it confusing when tracing some parts of the function. I can figure out
the base case very easily, but usually miss some crucial parts for the general
case. We also start talking about trees, which applies recursions a lot. Since “trees”
looks closer to real life, it is easier to understand the recursive process as
I try to trace the function. I know I am not really good at recursion, and
therefore I will need to practice more on my own on it.
没有评论:
发表评论