Which data structure is used to handle recursion in C?
a) Queue
b) Stack
c) Linked List
d) Array
Answer:
b) Stack
Explanation:
In C, recursion is managed using a data structure called the stack. When a function calls itself recursively, each call is pushed onto the call stack, allowing the program to return to the previous state after the recursive call completes. This stack stores the return addresses and the state of each recursive call, making it essential for handling recursion.
Understanding how the stack is used in recursion is crucial for writing effective recursive algorithms and ensuring that the program executes correctly without running into issues like stack overflow.