Computer Science EngineeringHardISRO SC (CS)

Trace this C function. int f(int n){ if(n==0) return 1; return n*f(n-1) - f(n/2); } (integer division) What does f(6) return?

  1. A. 2636
  2. B. 0
  3. C. -301
  4. D. -359

Correct answer: B. 0

Evaluating the recurrence by hand/computation gives f(6) = 0; the distractors correspond to a changed base case or a changed recurrence term.

More Algorithms, Data Structures & Programming (ISRO CS) questions

Exams that ask this topic