9618/23/M/J/24 question 3: worked solution (May/June 2024, paper 23)
Show as plain textHide plain text
Cambridge AS Level Computer Science 9618 · 10.2 Arrays Worked solution from the Data Types and Structures Paper 2 Problem-solving and Programming booklet, Part 2 of 4. Q28 9618/23/M/J/24 original Q3 Structured · 9 marks 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 IDEA Check 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 VIDEO ▶ Whole paper Video solution of the whole paper · by Pseudocode Pro. Tap the picture to open it on YouTube.