0
What is returned as a result of calling puzzle(22, 11)?
public static int puzzle(int i, int j) { if (i == j) { return 0; } else { return 1 + puzzle(i – 2, j – 1); } }
3 ответов
+ 2
11
i and j are decreasing by a factor of 2 and 1 respectively,
intitially i = 22 and j = 11,
recusion calling will stop when i==j, and it will reach when both i and j becomes 0,
recusion call ocuurs 11 times, 10 times it gave 1 and it last it gave 0,
so final result will be
1+1+.. 11times = 11
+ 1
options are :
StackOverFlowError
22
33
11
0
help