User interface language: English | Español

Date November 2017 Marks available 3 Reference code 17N.1.HL.TZ0.6
Level HL Paper 1 Time zone no time zone
Command term Determine Question number 6 Adapted from N/A

Question

Consider the following recursive method, where N is a positive integer

mystery(N)
if (N > 0) AND (N mod 2 = 0) then
mystery(N−2)
end if
output N
end mystery

Determine the output produced by the method call mystery(4).

Markscheme

Award up to [3] as follows:
[3] for fully correct response (sequence of output) “0;2;4”;
[2] for response (sequence) “4;2;0” (all elements are correct, but they are in inverse order);
[1] for response ”0” (only base case is correct);
OR
“0;2” (incomplete output, but initially correct, and with correct order);
OR
“–2;0;2;4”,“0;2;4;6” (correct sequence immersed in some unnecessary and incorrect context);

[0] in all other cases (e.g. responses “2”, “4”, “2;0”, “2;4”, “4;2”);

0
2
4

Examiners report

[N/A]

Syllabus sections

Topic 5: Abstract data structures » 5.1 Abstract data structures
Show 80 related questions
Topic 5: Abstract data structures

View options