A program uses two 1D arrays of type integer. Array1 contains 600 elements and Array2 contains 200 elements. Array1 contains sample values read from a sensor. The sensor always takes three consecutive samples and all of these values are stored in Array1. A procedure Summarise() will calculate the average of three consecutive values from Array1 and write the result to Array2. This will be repeated for all values in Array1. The diagram below illustrates the process for the first six entries in Array1. Array1 10 20 15 40 41 42 Array2 15 41 Comment average of first three values average of next three values Write pseudocode for the procedure Summarise().
- Write pseudocode for the procedure Summarise().[5]
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.
- [1] Procedure heading and ending and declaration of both indexes
- [1] Loop to process all elements from Array1
- [1] Sum (any) three consecutive values from Array1 and divide by 3 in a loop
- [1] Convert result to Integer
- [1] Assign value to correct element of Array2 in a loop
- [1] Increment Array2 index in a loop
- PROCEDURE Summarise() DECLARE Value : REAL DECLARE IXA, IxB : INTEGER // Index variables IxB <- 1 FOR IXA <- 1 TO 598 STEP 3 Value <- Array1[IxA] + Array1[IxA + 1] + Array1[IxA + 2] Value <- Value / 3 Array2[IxB] <- INT(Value) IxB <- IxB + 1 NEXT IXA ENDPROCEDURE
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 →