250 views

To remove recursion from a program we have to use which of the following data structure?

1. array
2. stack
3. queue
4. list
edited | 250 views

ans-Stack

for the recursion calls stack is used .If we execute a function which is calling itself again and again then with the help of stack recursion can be removed.
answered by Active (3.9k points)
i think it is array.because array fixed size,can't change it's size.
answered by (105 points)
reshown
0
but answe given is stack dont know why ,any strong reference to ur answer??
+1
yes it is stack.in the previous time i not focus the word "from a program".that means there already exists a recursion.we use stack for call recursion.

This recursion we can cancel by  using reverse the same recursion.

that is .....consider the function rec_factorial(5)

5->4->3->2->1(1*2*3*4*5)

then we can remove the same recursion by using another stack

1->2->3->4->5

sorry for the previous wrong answer.
0
what is "removing recursion " actuallly means??
0
Here removing recursion, meant that just cancel the effect of recursion from program.We can cancel recursion effect by using another stack.but program of that stack should be reverse of already existing recursion program.....just like

X-Y here we can remove effect of -Y using +Y....(actually we cancel effect of -Y instead of remove -Y)