Note AcademyNote Academy

Computer Science · May / June 2025 · Paper 1 TZ3 SL · Question 5

Adapt for 2027Tracing a loop with nested selection is taught, but the IB pseudocode should be rewritten in Python or Java.

IBCS

As printed in the paper

The question as text

5. Construct a trace table for the following algorithm: K = 1 S = 0 Z = 0 loop while K < 6 A = K mod 3 if A = 2 then S = S + K else if A = 1 then S = S - K else S = S + 1 end if end if Z = Z + S K = K + 1 end loop output ('The result: ', Z) [6]

Read automatically from the paper; the printed page above is exact.

Show the answer and mark scheme

Make a free account to save your answers and see your weak topics and ask the AI why a wrong answer is wrong.