Which data structure is used to perform recursion?

Stack data structure is used in recursion due to its last in first out nature. Operating system maintains the stack in order to save the iteration variables at each function call.

The correct answer to the question “Which data structure is used to perform recursion?” is that a stack data structure is typically used to perform recursion.

When a function is called recursively, each recursive call pushes information onto the call stack, including parameters, local variables, and the return address of the function. This stack-like behavior allows the program to keep track of multiple nested function calls. When the base case is reached and the recursion unwinds, the stack pops off these frames, allowing the program to return to earlier states.

So, in essence, the call stack acts as the data structure that facilitates recursion in most programming languages.