Skip to main content
A-LevelComputer ScienceData types and structures9618/42 · May/June 2023 · Q228 Marks

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.

  1. (a)Write program code to declare a record structure, SaleData, to store the data about each sale.[2]
  2. (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[4]
  3. (c)The function Enqueue(): • takes a new record as a parameter • inserts the record in the circular queue at the element pointed to by Tail • updates pointers and other variables as required • returns -1 if the circular queue is full • returns 1 if the record is stored successfully. Write program code for the function Enqueue().[6]
  4. (d)The function Dequeue(): • returns a null or empty record if the circular queue is empty • returns the first record in the queue if the circular queue is not empty • updates pointers and other variables as required. Write program code for the function Dequeue().[6]
  5. (e)The procedure EnterRecord(): • takes an ID and quantity as input and creates a sale record • uses Enqueue () to insert the record in the circular queue • outputs "Full" if the record was not inserted in the circular queue • outputs "Stored" if the record was inserted in the circular queue. Write program code for the procedure EnterRecord().[5]
  6. (f)(i)The following sale records need to be entered into the program: ID Quantity ADF 10 OOP 1 BXW 5 XXZ 22 HQR 6 LLP 3 Amend the main program to: • use EnterRecord() to input the six records in the table • use Dequeue () to remove one record • output either the ID and quantity of the removed record, or an error message if the circular queue is empty • use EnterRecord() to input the record with the ID "LLP" for a second time • output the ID and quantity for all the records currently stored in the array CircularQueue. Write program code to perform these tasks.[4]
  7. (f)(ii)Test your program. Take a screenshot of the output.[1]

Mark scheme

Marking points from the official mark scheme (May/June 2023). The mark or mark type is shown in brackets.

  1. [1] Record declaration named SaleData // class declaration (and end) named SaleData...
  2. [1] ...SaleID declared as string, Quantity as integer in record // if a class then a constructor assigning attributes SaleID and Quantity
  3. [1] Global array CircularQueue of 5 items of type SaleData
  4. [1] Global variables Head, Tail and NumberOfItems all initialised to 0
  5. [1] One record declared setting ID to "" and Quantity to -1
  6. [1] ...stored in all 5 array elements
  7. [1] Function Enqueue() header (and end) taking one parameter (type SaleData)
  8. [1] Checks if queue is full ...
  9. [1] and returns -1
  10. [1] (otherwise) Inserts parameter to CircularQueue[Tail]
  11. [1] increments Tail and resets to 0 if 5
  12. [1] Increments number of items and returns 1
  13. [1] Function header Dequeue() (and end where appropriate)
  14. [1] Checking if queue is empty...
  15. [1] ....and returning appropriate empty/null record/object/list element
  16. [1] (Otherwise) returning the item at Head
  17. [1] Incrementing Head and changing value 0 if it is 4/5
  18. [1] Decrement number of items
  19. [1] Procedure header EnterRecord (and end where appropriate) (ignore parameters)
  20. [1] Takes as input an ID (string) and quantity (integer)
  21. [1] Creates a record/object using inputs
  22. [1] Calls Enqueue () with record as parameter and stores/uses return value
  23. [1] Outputs "Full" and "Stored" in correct places
  24. [1] Calling EnterRecord() 6 times before dequeue
  25. [1] Calling Dequeue() and storing/using return value
  26. [1] checking if an empty record is returned and outputting either the ID and quantity of returned record or outputting the error message if empty record
  27. [1] Calling EnterRecord() again after dequeue
  28. [1] Output the ID and quantity for all the records currently stored in CircularQueue
  29. [1] 1 mark for screenshot showing: Data for 6 records input, 5 messages stating (e.g.) stored and 1 message stating (e.g.) full, 1 output of ADF 10 (dequeued), Repeat successful input of LLP 3, Output of the 5 records

Write your answer and get it marked

On Oracle Prep you can write or photograph your own answer and have it marked by AI against this mark scheme, with feedback on what you missed.

Sign up free →

About this question

Topic
Data types and structures, A-Level Computer Science (syllabus 9618). Structured question, 28 marks.
Source
A-Level Computer Science, May/June 2023 Paper 4 Variant 2, question 2.

Questions and mark schemes are from past examination papers and remain the copyright of the exam board. How Oracle Prep builds its content

Related Computer Science questions

© 2026 Oracle Prep