Page 4 - RECURSION
P. 4

Fibonacci Diagram























               Recursive GCD and LCM





























               Iteration vs Recursion
               Recursion and loops/iterations are related concepts.
               When a loop repeats, it uses same memory locations for variables and repeats the same unit of
               code, whereas in recursion fresh memory space is allocated for each recursive call.
               In a programming language, recursion involves an additional cost in terms of space used in RAM and
               in terms of time used by function call.

               Hence recursive versions of programs are slower and used extra memory in comparison to its
               equivalent iterative version. But, the code looks simpler and easy to understand using recursion.
   1   2   3   4   5