Recursion is very powerful, I haven't been programming for very long, in fact I've only been programming since last semester when I took CSC108. After about 5 months of learning how to code I didn't realize how much extra work I had been doing until I learned of recursion for recursion truly does take out a lot of unnecessary code. The process of recursion, from what I understand, is that of using a function inside of itself. A rather poor example of this would be the equation f(x) = f(x) + x^2. Obviously this function is a bad example, as you would continue to square x an infinite amount of times, but it gets you thinking about where recursion could work. From that equation you could say: "How do I end this?" or "When would this be useful?". It turns out to be useful in many different ways for instance you may want to create trees that repeat themselves in a certain pattern a certain number of times and this can be done much faster and much easier with recursion.
Recursion allows the programmer to make an infinite amount of iterations of a problem with only a finite amount of resources. If we could do that in every other field of the world we would run out of problems in our world pretty fast. Recursion does something very extraordinarily unique and that is why it's so powerful.
No comments:
Post a Comment