0
1.5kviews
Explain recursion as an application of stack with examples.

Mumbai University > Computer Engineering > Sem 3 > Data Structures

Marks: 10M

Years: May 2016

1 Answer
0
4views
  1. The High level Programming languages, such as Pascal, C etc. that provides support for recursion use stack for book keeping.
  2. Remember, in each recursive call, there is need to save the current values of parameters, local variables and the return address (the address where the control has to return from the call).
  3. Also, as a function calls to another function, first its arguments, then the return address and finally space for local variables is pushed onto the stack.
  4. Since each function runs in its own environment or context, it becomes possible for a function to call itself a technique is known as recursion.
  5. This capability is extremely useful and extensively used because many problems are elegantly specified or solved in a recursive way.
  6. The example of recursion as an application of stack is keeping books inside the drawer and the removing each book recursively.
Please log in to add an answer.