The power of recursion
5 01 2008Recursion can be a powerful technique for any programmer, but it’s important to understand its application, when it should be used and when it should not be.The whole idea behind recursion is to have a function or method which calls itself, this has the effect of breaking down the data in sub portions so that it can be handled easier. One of the most common applications for recursion is used injunction with tree data structures. In a tree data structure each node contains data and any number of sub nodes or children which may also contain data and any number of children.Here is a very common example of recursion in which we calculate the Fibonacci Number.
int fibonacci( int n ) { if( n == 0 ) return 0; if( n == 1 ) return 1; if( n > 1 ) return fibonacci(n-1) + fibonacci(n-2); }
Now you have a very small function, but powerful function that can easily and accurately compute a Fibonacci number. This is just one of the many useful applications of a recursive function. If I have peaked your interest I recommend that you continue reading about recursion, the wikipedia recursion article is a good start.

