The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
0 votes

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

  1. array
  2. stack
  3. queue
  4. list
asked in DS by Active (2.7k points)
edited by | 68 views

2 Answers

+2 votes

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 (2.9k points)
0 votes
i think it is array.because array fixed size,can't change it's size.
answered by (93 points)
reshown by
but answe given is stack dont know why ,any strong reference to ur answer??
yes it is 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)


then we can remove the same recursion by using another stack



sorry for the previous wrong answer.
what is "removing recursion " actuallly means??
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)

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

36,992 questions
44,560 answers
43,623 users