Recursion is a programming technique where a function calls itself.
To manage these nested function calls, the system uses a call stack.
When a function is called, an activation record (or stack frame) is created and pushed onto the call stack. This record contains information about the function call, such as its parameters, local variables, and the return address (where execution should resume after the function finishes).
In a recursive function, each time the function calls itself, a new activation record is pushed onto the stack.
When a recursive call returns, its activation record is popped off the stack, and execution resumes at the point specified by the return address in the new top-of-stack record.
This LIFO (Last In, First Out) behavior is perfectly managed by a stack data structure. Therefore, a stack is the underlying data structure used to implement recursion.