I must say that, upon first being introduced to recursion, I was not entirely sure as to what its significance was. Using "for loops" and "while loops" had always worked for me, and so I had seen no need for anything else. It was also somewhat difficult at first for me to grasp recursion, despite its simplicity, and so that proved to be another deterrent. However, upon further inspection of examples, and my own experiences with attempts to use it, I found that it became quite handy. Its use of short and usually simple code made it desirable for use instead of a "for loop" or a "while loop", which would sometimes become quite long and redundant. I also found that it proves to be much more versatile in its uses, as it has the potential to perform iterations many more times with fewer steps than any of the loops, while also being capable of doing more than a loop with an equivalent or even longer length of code.
This week's biggest problem, though, came from the lab work. My partner and I were having extreme difficulties with the finalization of our first recursion code, and we could not tell at all where the problem was originating from. Therefore, we decided to move on to the freeze code, which we finished relatively quickly, in order to clear our minds of the first code. We ended up staying at the lab a good half hour more than we were meant to in order to finish the code and determine the source of the problem. We were literally at our wits end, until finally, almost as a joke, we decided to add "return" to the end of our code, thinking that it couldn't possibly be the source of our misery. Lo and behold though, our code worked perfectly after this, and we laughed at ourselves for missing such a simple, but important problem.
No comments:
Post a Comment