1.

What data structure would you mostly likely see in non recursive implementation of a recursive algorithm?(a) Linked List(b) Stack(c) Queue(d) TreeMy doubt stems from Stack Operations topic in chapter Abstract Data Types of Data Structures & Algorithms II have been asked this question in an interview.

Answer»

The correct answer is (b) Stack

Explanation: In recursive algorithms, the order in which the recursive process comes back is the REVERSE of the order in which it GOES forward during execution. The compiler uses the stack data STRUCTURE to implement recursion. In the forwarding phase, the values of local variables, parameters and the return address are pushed into the stack at each recursion level. In the backing-out phase, the STACKED address is popped and used to execute the REST of the code.



Discussion

No Comment Found

Related InterviewSolutions