Which data structure is used to perform recursion?
or,
What is the data structure used to perform recursion?
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.
Stack is the data structure used to perform recursion.
Explanation:
Because of its LIFO (Last In First Out) property, it remembers its ‘caller’ so knows whom to return when the function has to return. Recursion makes use of the system stack for storing the return addresses of the function calls.
Every recursive function has its equivalent iterative (non-recursive) function. Even when such equivalent iterative procedures are written, an explicit stack is to be used.