This pseudocode represents an algorithm. An input of -1 will terminate the algorithm. DECLARE Count : INTEGER DECLARE Answer : INTEGER DECLARE Value : INTEGER REPEAT INPUT Value IF Value <> -1 THEN Answer ← Value FOR Count ← Value - 1 TO 1 STEP -1 Answer ← Answer * Count NEXT Count OUTPUT Answer ENDIF UNTIL Value = -1
- (a)Complete the trace table for the input data: 5, 6, -1, 20, 9, 4 Value | Count | Answer | OUTPUT --- | --- | --- | ---[5]
- (b)State the purpose of this algorithm.[1]
- (c)Describe the problem that would be caused in this algorithm if a Value of 1, 0 or less than -1 was input.[2]
Mark scheme
Marking points from the official mark scheme (Oct/Nov 2024). The mark or mark type is shown in brackets.
- [1] Correct Value column
- [1] Correct Count column
- [1] Correct Answer column (down to first OUTPUT (120)) – Shaded grey
- [1] Correct Answer column (remaining rows)
- [1] Correct OUTPUT column
- [1] It multiplies the input number by one less than itself repeatedly, until the value is 1
- [1] It calculates the number of permutations of all the numbers up to the input value
- [1] The program would accept the value and enter the FOR loop
- [1] Count would keep reducing by 1 and would never reach 1, as it would already be less than 1
- [1] There would be an endless loop
Write your answer and get it marked
On Oracle Prep you can write or photograph your own answer and have it marked by AI against this mark scheme, with feedback on what you missed.
Sign up free →