After reading the chapter on Recursion in my book, it posed a very interesting statement:
I understand it is all about choosing the right style for the job in hand, so why teach me somthing when it is deemed as bad to do? Im interested to know if what they have told me is somthing I need to look at, and avoid recursion in my programs.Recursion has many negatives. It repeatedly invokes the mechanism, and consequently the overhead, of function calls. This can be both expensive in both processor time and memory space. Each recursive call causes another copy of the function variables to be created, this can comsume considerable memory.
Iteration normally occurs within the function, so the overhead of repeated function calls and extra memory assignment is omited.
So, why choose recursion?