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
D. Stack
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.
Depth First Search (DFS)
Tree traversals (Inorder, Preorder, Postorder)
All use Stack in their non-recursive implementation.
Attempt Quiz Now:
BPSC Tre 4.0 DSA Practice Set