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

Options

  • A. Queue
  • B. Tree
  • C. Linked List
  • D. Stack

Correct Answer (Detailed Explanation is Below)

D. Stack

Detailed Explanation

Recursive algorithms use the call stack internally to store:

  • Function calls

  • Local variables

  • Return addresses

When we convert a recursive algorithm into a non-recursive (iterative) version, we explicitly use a Stack data structure to simulate the recursive call stack.


 Example:

  • Depth First Search (DFS)

  • Tree traversals (Inorder, Preorder, Postorder)

All use Stack in their non-recursive implementation.

OOps! You are currently offline.