Consider the following code:

public int result(int n) {
  if (n == 1)
    return 2;
  else
    return 2 * result(n - 1);
}

If n > 0, how many times will "result" be called to evaluate "result(n)"?

n
  • 2
  • 2^n
  • 2n
  • n^2

On each call, n is decremented by 1, until it reaches 1 when it hits the base case.