Recursion and Call Stack
Recursion is a technique in which a function calls itself to solve a problem by reducing it to smaller instances of the same problem. A recursive solution requires a base case to terminate the recursion.
Each recursive call creates a new stack frame containing local variables, parameters, and the return address. These frames remain on the call stack until the recursive calls return. Excessive recursion can therefore cause stack overflow.
Every recursive solution needs a termination condition.
Each call creates a call-stack frame.
Recursive calls are unwound in reverse order.
Deep recursion can cause stack overflow.
Many recursive algorithms can be converted into iterative solutions.
0-2 years experience
2-5 years experience
5-8 years experience
8+ years experience