Cambridge AS Level Computer Science 9618 · 10.2 Arrays

Q28 · 9618/23/M/J/24 Q3

Worked solution from the Data Types and Structures Paper 2 Problem-solving and Programming booklet, Part 2 of 4.

Q289618/23/M/J/24original Q3Structured · 9 marks
Question 3 from 9618/23/M/J/24

Worked solution

(a)(i)

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).

(a)(ii)

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]

(b)

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]

KEY IDEACheck a value with two comparisons joined by AND, and set up a flowchart loop with an initial step, a counter and an exit test.
TOTAL 9 marks

Official mark scheme

Mark scheme for 9618/23/M/J/24 question 3
VIDEO
▶ 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.