4 The program flowchart represents a simple algorithm.
- (a)Write the equivalent pseudocode for the algorithm represented by the flowchart.[6]
- (b)Give the name of the iterative construct in the flowchart.[1]
This question uses a diagram from the original paper, which isn't shown here. Open the full paper from the past papers archive to see it.
Mark scheme
Marking points from the official mark scheme (Oct/Nov 2022). The mark or mark type is shown in brackets.
- [6] (a) One mark per point: 1 Input UserID and use of GetAverage() and assignment 2 Initialisation of Total to zero and Index to 4 3 Conditional loop with Index from 4 to 6 4 Assignment of Last from element SameMonth[Index] in a loop 5 Structure: IF...THEN...ELSE...ENDIF in a loop 6 Correct assignments and final call to Update () after the loop INPUT UserID Average <- GetAverage(UserID) Total <- 0 Index <- 4 WHILE Index < 7 // REPEAT Index <- Index + 1 Last <- SameMonth[Index] IF Average > Last THEN Total <- Total + Average ELSE Total <- Total + Last ENDIF ENDWHILE // UNTIL Index = 7 CALL Update(UserID, Total) Alternative solution using FOR loop: One mark per point FOR loop solution: 1 Input UserID and use of GetAverage() and assignment 2 Initialisation of Total to zero 3 loop Index from 4 to 6 4 Assignment of Last from array SameMonth in a loop 5 Comparison IF...THEN...ELSE...ENDIF in a loop 6 Appropriate assignments in a loop AND final call to Update () after the loop INPUT UserID Average <- GetAverage (UserID) Total <- 0 FOR Index <- 4 TO 6 Last <- SameMonth [Index] IF Average > Last THEN Total <- Total + Average ELSE Total <- Total + Last ENDIF NEXT Index CALL Update (UserID, Total)
- [1] (b) Pre-condition (loop) / count-controlled (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 →