Recursion
Out of the three topics we are assigned
with, I have the most amount of confidence with respect to my understanding of
Recursion, and that is why I will proceed with discussing this topic. The
concept of recursion is a fundamental concept in computer science. It is a
process of defining a function in which the function will be applied to the
function itself. You can think of recursion as pointing two mirrors at each
other, and each mirror will show the reflection of itself. Recursion is useful
many aspects of computer science. So far we have used recursions to break down
lists within lists and produced a result. For instance, we used the recursive
method sum_list to find the sum of all lists within a list. There are of course,
many other applications of recursion, in which we can use to solve complex
problems in computer science.
The power of Recursion extends way beyond
the method sum_list. Recursion is a powerful program technique that can solve
almost all combinatorial problem. One application of recursion we learned in
CSC148 is trees. Trees are recursive objects because they involve a simple base
case and a set of rules that reduce all the other cases towards this simple
base case. The fundamental key of writing a tree is to establish a base case. Once
a base case is established, the rest will likely follow. The base case is
basically a condition in which the recursion ceases to continue, and produces a
result. After we establish a base key, we can then write a recursive function
that will keep on recurring until the condition of the base key is met. The
power of tree to solve complicated nests is just a mere demonstration of the
power of recursion. This concept is perhaps one of the most useful techniques
in programming languages that I will continue to encounter in my future
studies.
Currently I find the level of difficulty
with recursion to be rather fair. I was always able to establish the base case
and often had no problem to write the recursive. However, using recursion to
write minimax method for A2 was especially challenging, which just shows that I
have a lot more to work on with respect to this topic.
没有评论:
发表评论