GATE CS 2026, set 1 · Question 61 · Programming and Data Structures · Numerical answer (NAT) · 2 marks · no negative marks

Consider the recursive functions represented by the following code segment:
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.

Answer

Answer 65536

Answer from the official GATE CS 2026 answer key.

The step-by-step solution, where available, is part of GATE CS Pro. See what Pro includes