Master Mathematics.

Programming · Recursion, Divide & Conquer, Greedy & DP · Problem 1

Counting the calls of a recursion

Consider

def mystery(n):
    if n <= 0:
        return 1
    else:
        return mystery(n-1) + mystery(n-2)

How many function calls (including the first) are made to compute mystery(4)?

  1. (A)
  2. (B)
  3. (C)
  4. (D)

Source: GATE DA