Week 7
Recursion is a funny thing. Try googling it. Did you mean recursion? I really appreciate sense of humour surrounding recursion. It makes it all the more fun. Even the programming language PHP pokes fun at itself by being a recursive backronym, PHP: Hypertext Preprocessor. But it also seems like very useful and elegant way to write code, however difficult it is to wrap one's head around it at first. The thought of calling a function in a function is somewhat mind boggling to me. It reasons that there must be a stop condition, kind of like writing a while loop, so we don't get an infinite loop. And the reduction in lines to write is an added bonus. In some cases it will save time and memory, or might even be the only way to write a certain function.
In researching a little, I found that there are many types of recursion; direct, indirect, single, multiple, anonymous. And that they play a key role in some abstract data types. Professor Heap gave us an awesome demonstration making a fractal with some recursive code, which I was awed by. I hope after this class that I'll have that figured out. It seems that recursion and list comprehension go pretty hand in hand, so it looks like I will get the practice on list comprehension that I was eager to get last week. Now that we're getting recursion under our belts, it looks as though our data structures are getting more and more complex. We've had a glimpse of trees in class but I think we've only just scratched the surface in terms of what they can represent.
It seems like I'm going to need a lot of practice to really internalize recursion. Good thing there are some additional exercises with the lab this week and I believe there are some others on the slides. Now all's I need to is find the time in which to practice. That said, I looking forward to learning more on this fascinating technique and honing my recursive skills in the lab this week as well as on assignment 2.
No comments:
Post a Comment