GATE DA 2026 — Question 39

Programming, Data Structures and AlgorithmsProgramming in PythonMCQ2 marks · −2/3 if wrongMedium

A recursive function in Python is given.
python
1def mystery(n):
2    if n <= 0:
3        return 1
4    else:
5        return mystery(n-1) + mystery(n-2)
6
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
Practise the full 2026 paper
Challenge a friend: WhatsApp Telegram
Recommended book · affiliate linkIntroduction to Algorithms (CLRS)The standard reference behind most GATE algorithm questions.
Practise more on Programming in PythonTimed, in the real exam interface · free to start

A GATE question every morning

One real past-paper question every morning for your branch, answer hidden until you tap. Free on Telegram.

Join
Stuck? Ask in the student group