GATE Computer ScienceVery hardGATE CSE · NIELIT

int A(int m, int n) { if (m == 0) return n+1; if (n == 0) return A(m-1, 1); return A(m-1, A(m, n-1)); } Including the first call, how many invocations of A occur while evaluating A(2, 3)?

  1. A. 30
  2. B. 70
  3. C. 88
  4. D. 44

Correct answer: D. 44

A(2,3) = 9; counting every invocation of the recursion (a(2,n) = 2n+3 style growth) gives 44 calls.

More Programming and Data Structures (GATE) questions

Exams that ask this topic