Login or Create an Account to view the mark scheme, comment, and add to a test
Consider the following algorithm.
function fun(N) if N = 0 then return 1 else if (N % 2 == 0) return N - fun(N-1) else return N + 2 × fun(N-1) end if end function
(a).
State what would occur if the first "if statement" were removed.
[1]
(b).
Trace the algorithm when N=4 by completing the following trace table.
[3]
N | fun(N) returns ------------------- 4 | 3 | 2 | 1 | 0 |
(c).
State the final output of the algorithm when N=4.
[1]

Extended Response5 MarksPremium
23 Uses80 Views1 Like