The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
0 votes
68 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
asked in DS by Active (2.7k points)
edited by | 68 views

2 Answers

+2 votes
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 (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
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)


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
126,740 comments
43,623 users