Recursive Method Analysis
Consider the following incomplete method.
public int mystery(int x)
{
if (x <= 1) {
return 1;
} else {
return ( /* missing code */ );
}
}
Which of the following expressions can replace /* missing code */ so that the method call mystery(10) returns the value 32?
A
2 * mystery(x – 1)
B
4 + mystery(x – 1)
C
2 * mystery(x – 2)
D
4 * mystery(x – 4)
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | songqiuhui2012 | 1 | 1 | 0m 14s | 86 |
| #2 | singhris000 | 1 | 1 | 0m 27s | 73 |
| #3 | richa.tuli | 2 | 2 | 3m 17s | 3 |
| #4 | ethan | 1 | 4 | 3m 40s | -150 |
| #5 | suhanakochhar006 | 1 | 2 | 4m 21s | -171 |
APFIVE