Tail recursion Pick ONE option
MathWorks technical mcq question, verified with a worked answer. Free to practise - no sign-up.
Tail recursion**
Pick ONE option
Show answer & explanation
Tail recursion is defined as a recursive call that appears as the final operation in a function, before the function returns. This allows compilers to optimize it into iteration (tail-call elimination), avoiding stack overflow. Options B, C, and D describe recursion in general, the call stack/activation records, and variable binding respectively—not the defining characteristic of tail recursion.
Step-by-step Derivation:
Tail recursion is a specific optimization pattern in recursion. The key criterion is that the recursive call must be the last executable statement. When this occurs, the compiler can reuse the current stack frame for the recursive call instead of allocating a new one, making it as efficient as a loop. Option A captures this exact definition. Option B is too vague (any recursion 'includes' a recursive call). Option C describes the call stack mechanism, not tail recursion. Option D describes name binding/scope resolution, which is unrelated.