GATE DA 2026 · Question 39 · Programming, Data Structures and Algorithms · Multiple choice (MCQ) · 2 marks · −2/3 for a wrong answer

A recursive function in Python is given.
def mystery(n): if n <= 0: return 1 else: return mystery(n-1) + mystery(n-2)
Now, consider the following function call:
mystery(4)
Assume that a typical runtime stack is used to manage function calls. Each function call is pushed onto the stack and removed only after it finishes execution.
Which of the following options denotes the total number of function calls (i.e., the total number of stack activations), including the initial call, to compute mystery(4)?

  1. (A) 5
  2. (B) 9
  3. (C) 15
  4. (D) 17
Answer

Answer (C)

Answer from the official GATE DA 2026 answer key.

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