Past-paper question · 2023 May-June · Paper 42 · Q2(b)

Question 2(b) 2023 · May-June · Paper 42 · 4 marks

Original past-paper question for 2(B)
Original past-paper question for 2(B)
Reveal official mark-scheme answer Official mark-scheme answer for 2(B)

Official answer for Question 2

Part (b)

Question 1

mark each

Question 4

✓
Global array CircularQueue of 5 items of type SaleData
✓
Global variables Head, Tail and NumberOfItems all initialised to 0
✓
One record declared setting ID to "" and Quantity to -1 …
✓
...stored in all 5 array elements
✓
Example Program code:
✓
Java
✓
public
✓
static
✓
SaleData[] CircularQueue = new SaleData[5];
✓
public
✓
static
✓
Integer NumberOfItems = 0;
✓
public
✓
static
✓
Integer Head = 0;
✓
public
✓
static
✓
Integer Tail = 0;
✓
public static void main(String args[]){
✓
for(Integer X = 0; X < 5; X++){
✓
CircularQueue[X] = new SaleData("",-1);
✓
}}
✓
VB.NET
✓
Dim CircularQueue(0 To 4) As SaleData
✓
Dim NumberOfItems As Integer
✓
Dim Head As Integer
✓
Dim Tail As Integer
✓
Sub Main()
✓
NumberOfItems = 0
✓
Head = 0
✓
Tail = 0
✓
For x = 0 To 4
✓
CircularQueue(x).SaleID = ""
✓
CircularQueue(x).Quantity = -1
✓
Next
✓
End Sub
✓
9618/42
✓
Cambridge International AS & A Level – Mark Scheme
✓
May/June 2023
✓
PUBLISHED
✓
Question
✓
Answer
✓
Marks

Mark scheme 9618_s23_ms_42.pdf →

Show text version of question

Question 2

Part (b)

Question 2

A business sells a single product. Customers can purchase one or more of this product.

Each sale has an ID and a quantity, for example "ABC" and 2

The business needs a program to store the data about the sales in a circular queue data structure.

Part (b)

Write program code to:

  • declare a global array, CircularQueue, of 5 items to store the sale records
  • declare the global pointers Head and Tail
  • declare the global variable NumberOfItems
  • initialise all elements of the array CircularQueue to an empty record, where the ID is
  • null ("") and quantity is -1

  • initialise Head, Tail and NumberOfItems to 0

Save your program.

Copy and paste the program code into part 2(b) in the evidence document.

[4]
Topic relevance

Why this question appears here

82% assigned-topic match · Data types and structures › Data types and records

Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.

Permanent source page: Educate A Change · From 9618_s23_qp_42.pdf

Keep practising this topic