Whats happen if base condition is not defined in recursion Stack underflow Stack Overflow Both A B None of the above

Correct Answer:

Stack Overflow

Analyzing the Answer:

If a base condition is not defined in a recursive function, the function will call itself repeatedly without ever stopping. Each recursive call adds a new stack frame to the call stack. Eventually, the call stack will run out of space, leading to a stack overflow error.

Analysis of other options:

☐ Stack underflow: Stack underflow happens when you try to pop an element from an empty stack. This is not directly related to the lack of a base case in recursion.

☐ Both A & B: Only a stack overflow occurs in this scenario.

☐ None of the above: This is incorrect; a stack overflow is the direct consequence of a missing base case in recursion.

Read more here: Source link