GATE CS 2015, set 3 · Question 38 · Programming and Data Structures · Multiple choice (MCQ) · 2 marks · −2/3 for a wrong answer

Consider the following recursive C function.
void get(int n) { if (n<1) return; get(n-1); get(n-3); printf("%d", n); }
If get(6) function is being called in main() then how many times will the get() function be invoked before returning to the main()?

  1. (A) 15
  2. (B) 25
  3. (C) 35
  4. (D) 45
Answer

Answer (B)

Answer from the official GATE CS 2015 answer key.

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