Interview Question

What is recursion?

A recursive function solves a problem through smaller calls and needs a base case.

💡 Concept ✅ Quick Revision ⚙ C

Answer

Recursion occurs when a function calls itself directly or indirectly. • A terminating condition must stop further recursive calls. • Each active call has its own parameters and automatic objects. • Excessive recursion can exhaust implementation resources.

💡 C Example

unsigned int factorial(unsigned int value) { return value < 2 ? 1U : value * factorial(value - 1U); }

⚡ Quick Revision

A recursive function solves a problem through smaller calls and needs a base case.