Question 5

OCR Computer Science June 2023 Algorithms and programming (H446-02)A level8 marks

On the specification

(a)
2.2 Problem solving and programming
(b)
2.2 Problem solving and programming
Question text

5 A recursive pseudocode function, recursiveAlgorithm(), is shown. 1 function recursiveAlgorithm(value) 2 if value <= 0 then 3 return 1 4 elseif value MOD 2 = 0 then 5 return value + recursiveAlgorithm(value – 3) 6 else 7 return value + recursiveAlgorithm(value – 1) 8 endif 9 endfunction (a) Describe the key features of a recursive algorithm. You may refer to the function, recursiveAlgorithm() in your answer. [3] (b) Trace the recursive function, recursiveAlgorithm(), and give the final return value when called with recursiveAlgorithm(10). You may choose to use the table below to give your answer. Function call value return Final return value [5]