Page 3 - RECURSION
P. 3

  Each time a new recursive call is made, a new memory space is allocated to each local
                       variable used by the recursive routine i.e. During each recursive call the local variable of the
                       recursive function gets a different set of values, but with the same name.

               When a function call happens previous variables gets stored in stack















               Returning values from Base class to caller function













               Advantages and Disadvantages of Recursion
               Advantages of Recursion:
                     For a recursive function, you only need to define the base case and recursive case, hence
                       recursion can lead to more readable and efficient algorithm descriptions.
                     Some problems are inherently recursive, such as Graph and Tree Traversal.
               Disadvantages of Recursion:
                     It consumes more storage space because the recursive calls along with local variables are
                       stored on the stack.
                     The computer may run out of memory if the recursive calls are not checked.
                     It is less efficient in terms of speed and execution time.

               Recursive Fibonacci Series
   1   2   3   4   5