Last week in class, we learned about recursion. A strange way in which a function can call itself in the function. Recursion is strange in that the function calls itself. This would seem as though the function is incomplete or that an infinite loop would be created. However, recursion works, and in order to understand it, smaller and simple examples must be examined and understood. That is what we did in class. In order for us to understand recursion, we must be able to examine the function and how the function works with simple examples, and then other more complex examples. In this way, recursion can be better understood.
I had trouble understanding recursion, when it was first introduced. However, tracing the examples really helps to explain recursion. Similarly, I had trouble implementing recursion, a trouble I may still be suffering. I understand the concept of recursion quite well, thanks to the examples. However, actually having to implement recursion is something I find difficult. Understanding when exactly I should use recursion and the way in which it should be implemented is something I struggled with that week. There seems to be a sort of "formula" or "form" in writing recursion code, where there is an "if...else" statement. The "else" statement is usually important for (tracing) the simplest recursion call. The "if" statement is harder to write, and where I have the most difficulty. Hopefully, practicing and writing more code should help me overcome this problem. Also, I plan on researching recursion more and looking at recursion code more, in order that I familiarize myself with recursion.
Additionally, in lab, this week I used the python visualizer to trace recursion calls. This helped to solidify how and why recursion works. This also made it easier for me to understand the way the function is implemented. All in all, tracing code to understand the concept and practicing problems to implement it, will give me a better understanding of recursion.
No comments:
Post a Comment