?

AP® Computer Science A

Free Version

Upgrade subject to access all content

Moderate

Recursion: Determining Missing Code

APCSA-DNNZYG

Consider the following incomplete method.

 public int mystery(int x)
 {
  if (x <= 1)
  return 1;
  else
  return <missing code>;
 }

Which of the following could be used to replace missing code so that the value of mystery(10) is 32?

A

2 * mystery(x - 2)

B

mystery(x - 1) + mystery(x - 2)

C

2 + mystery(x - 1)

D

4*mystery(x - 4)

E

4 + mystery(x - 1)