Programming and Data Structures · Recursion
Official IIT answer key · IIT Kanpur · Audited Aug 2026
GATE CSE 2015 Set 3 Q39 · MCQ · 2 marks
void get(int n)
{
if (n<1) return;
get(n-1);
get(n-3);
printf("%d", n);
}
If get(6) function is being called in main() then how many times will the get() function be invoked before returning to the main()?Key concept
No account needed
Sit 5 related RecursionPYQs as a guest. We'll score the set and show which traps cost marks — sign in only if you want to save the run.
Topic notes
GATE tests Recursion primarily through direct execution tracing of recursive C code snippets, stack-unwinding behavior (pre-order vs. post-order execution), and termination/infinite recursion analysis. Questions frequently incorporate static variables, pointer/reference aliasing, mutual recursion, and tree/array traversals to test whether candidates can systematically maintain call frames. In recent years, the focus has expanded from standard tracing to higher-order mathematical characterizations (e.g., finding the smallest input or maximum output value of composed recurrences).
Full Recursion guide →Consider the following recursive C function. void get(int n) if (n If get(6) function is being called in main() then how many times will the get() function be invoked before returning to the main() ?
Topic-wise GATE CS PYQs with verified steps
Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.
