GATEverse Practice, past papers & mock tests
GATE 2026 · CS1 - Forenoon
Programming & Data StructuresProgramminghardNAT2 marks
Consider the recursive functions represented by the following code segment:
c
int bar(int n){ if (n == 1) return 0; else return 1 + bar(n/2); }
int foo(int n){ if (n == 1) return 1; else return 1 + foo(bar(n)); }
The smallest positive integer n for which foo(n) returns 5 is ______. (answer in integer) Note: Ignore syntax errors (if any) in the function.
Save your progress

Related Programming & Data Structures PYQs