Worked solution from the Data Types and Structures Paper 2 Problem-solving and Programming booklet, Part 2 of 4.
Use the record field with the index, and check both limits. Either an AND or an OR clause scores:
IF Batch[ThisIndex].Weight >= Min AND Batch[ThisIndex].Weight <= Max THEN
Uses Batch[ThisIndex].Weight [1]
A valid check for one boundary [1]
A valid check for the other boundary with the correct operator (AND here) [1]
Another accepted way: IF Batch[ThisIndex].Weight < Min OR Batch[ThisIndex].Weight > Max THEN (this tests for a weight outside the range).
Write one of these: set the Item_ID field to an empty string (or NULL or another invalid value), or set Weight to 0 or less [1]
Fill the empty flowchart boxes in order from the top. One mark for each zone:
Zone 1, first box: write Set Index to 0 and Set Count to 0 [1]
Zone 2, the empty box above the Index decision: write Set Index to Index + 1 (the decision Is Index = 1001? is already printed; Yes goes to END) [1]
Zone 3, first diamond below that: write Is InRange(Index) = TRUE? (Yes goes back to the loop, No goes down) [1]
Zone 4, box on the No path: write Set Count to Count + 1 [1]
Zone 5, last diamond and output: diamond says Is Count > 5? (No goes back to the loop, Yes goes to the output box), output box says OUTPUT a warning message such as "Reject Batch" and then goes to END [1]
▶ Whole paper
Video solution of the whole paper · by Pseudocode Pro. 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.