Consider the following definition of a recursive function f.
int f( int n ) { if( n == 0 ) return 0; if( (n & 1) == 0 ) return f(n/2); return f(n/2) + 1; }
What does f compute?
Assuming non-negative arguments, what is the purpose of the following recursive function?
int ff( int n, int m ) { if( n == 0 ) return m; return ff( n-1, m*n ); }
Consider the following definition of a recursive function ff.
int ff( int n, int m ) { if( n == 0 ) return m; return ff( n - 1, m + 1 ); }
If the values of n and m are nonnegative, what is returned by ff( n , m )?
int ff( int n, int m ) { if( n == 0 ) return 0; return ff( n - 1, m ) + m; }
int f( int x ) { if( x == 0 ) return 1; return x * f( x ); }
For which inputs x will the call f(x)terminate?
Consider the following definition of a recursive function what?
int what( int (*f)(int), int x, int n ) { if( n == 0 ) return x; return f( what( f, x, n - 1 ) ); }
If n is a non-negative integer, then the call what( f, x, n )returns