Worked solution from the Data Types and Structures Paper 2 Problem-solving and Programming booklet, Part 2 of 4.
There are five grade boundaries. Upper is the boundary plus 2. The mark is within range if it is at least Lower and at most Upper.
FOR Index ← 1 TO 5
Lower ← GB[Index] - 2
Upper ← GB[Index] + 2
IF Mark >= Lower AND Mark <= Upper THEN
OUTPUT "Check this paper"
ENDIF
NEXT Index5 [1]
GB[Index] + 2 (or Lower + 4) [1]
>= Lower [1]
<= Upper [1]
Use the mark as an index.
Use Mark as the index of the Check array [1]
If that element is TRUE, the paper must be checked [1]
Set every element to FALSE first. Then for each boundary set the five elements from boundary - 2 to boundary + 2 to TRUE.
PROCEDURE GBInitialise()
DECLARE GBIndex, GBMark, ThisIndex : INTEGER
FOR ThisIndex ← 0 TO 75
Check[ThisIndex] ← FALSE
NEXT ThisIndex
FOR GBIndex ← 1 TO 5
GBMark ← GB[GBIndex]
FOR ThisIndex ← GBMark - 2 TO GBMark + 2
Check[ThisIndex] ← TRUE
NEXT ThisIndex
NEXT GBIndex
ENDPROCEDUREProcedure heading and ENDPROCEDURE [1]
All elements of Check set to FALSE first [1]
Loop through the GB array [1]
Boundary mark taken from GB [1]
Loop over the five marks from boundary - 2 to boundary + 2 [1]
Each of those Check elements set to TRUE [1]
Another way that scores: loop 0 to 75 and test each index against all five boundaries, setting TRUE or FALSE.
▶ Whole paper
Video solution of the whole paper · by Zafar Ali Khan (ZAK). Tap the picture to open it on YouTube.
Solutions follow the official Cambridge mark schemes; marks are shown in grey. Videos are from other YouTube channels. Paper codes read component / series / year: M/J = May/June, O/N = October/November. Past-paper questions © UCLES, reproduced for classroom practice.