Recursion Flashcards
(8 cards)
What is recursion?
When a subroutine calls itself during its execution.
When does recursion stop calling itself
Until a certain condition is met, called the stopping condition.
Advantage of recursion?
For cerain problems, they can be represented in less lines of code.
What happens each time the function calls itself?
A stack frame is created within the call stack.
What is stored in the stack frame?
Parameters, local variables and return addresses
Whats the point of the stack frame?
It allows the subroutine to return to that specific point during its execution.
What is the meaning of the subroutine ‘unwinding’?
The process of information from the call stack being popped off the stack.
Disadvantages to recursion?
Inefficient use of memory.
Danger of stack overflow if the subroutine calls itself too many times.