top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What data structure would you mostly likely see in a non recursive implementation of a recursive algorithm?

+3 votes
1,703 views

What data structure would you mostly likely see in a non recursive implementation of a recursive algorithm?

posted May 12, 2016 by Hasan Raza

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button
Stack  is a very good example for this case.
What is the reasoning of it @Manikandan
Probably, you would see a stack. A recursive algorithm works by calling itself each time with different data. So, to simulate that without actual recursion,you would need to track the changing data on some kind of stack. This would allow the data to be processed in a last-in-first-out order, which is how recursion works

1 Answer

–1 vote

A recursive algorithm works by calling itself, each time with different data. So, to simulate that without actual recursion, you would need to track the changing data on some kind of stack. This would allow the data to be processed in a last-in-first-out order, which is how recursion works.

answer May 14, 2016 by Kapil Kumar
I think u misread the question, question is about which datastructure...
Similar Questions
+4 votes

How to write Euclid's GCD non-recursive algorithm? Sample C/C++ code would be a great help.

+2 votes

getRandom() should pick a "random" element from your data structure, and should not be predictable (for instance always picking the "first" element from your DS)

...