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 Loyal (6.7k points)
edited by | 250 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 (3.9k points)
0 votes
i think it is array.because array fixed size,can't change it's size.
answered by (105 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)

Related questions

+7 votes
5 answers
0 votes
1 answer
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
48,691 questions
52,776 answers
68,389 users