Which of the following data structures is used to implement recursion?
a) Stack
b) Queue
c) Linked List
d) Tree
Answer:
a) Stack
Explanation:
Recursion is implemented using a stack data structure. Every recursive function call is pushed onto the stack, and when the function returns, it is popped off the stack.
This behavior mimics the Last-In-First-Out (LIFO) nature of stacks. Each function call waits until the next call finishes, and results are returned in reverse order of the calls.
This structure allows recursion to track and maintain the state of each call in memory, preventing overlapping and maintaining execution order.
Reference:
DSA (Data Structures and Algorithms) MCQ Questions and Answers