Skip to main content
A-LevelComputer ScienceData types and structures9618/41 · May/June 2025 · Q120 Marks

A program stores positive integers in a circular queue. The queue is stored as a global 1D array of 20 integers with the identifier Queue. Each index is initialised with the data -1 The global variable HeadPointer, initialised to -1, points to the first element in the queue. The global variable TailPointer, initialised to −1, points to the last element in the queue. The global variable NumberItems, initialised to 0, stores the number of items in the queue.

  1. (a)Write program code to declare and initialise Queue, HeadPointer, TailPointer and NumberItems[2]
  2. (b)The function Enqueue(): • takes an integer as a parameter • checks if the queue is full • returns FALSE if the queue is full • stores the parameter in the next position in the queue and returns TRUE if the queue is not full • updates the appropriate pointers and NumberItems Write program code for Enqueue()[6]
  3. (c)The main program: • attempts to store each of the integers 1 to 25 (inclusive) in the queue in ascending numerical order using Enqueue() • outputs the integer that was passed to Enqueue() and "Successful" if it was stored in the queue, or "Unsuccessful" if it was not stored in the queue. For example: Ο if the integer 5 is passed to Enqueue() and is stored in the queue, the output will be: "5 Successful" Ο if the integer 23 is passed to Enqueue() and is not stored in the queue, the output will be: "23 Unsuccessful" Write program code for the main program.[3]
  4. (d)The function Dequeue() returns -1 if the queue is empty. If the queue is not empty, the function returns the next item in the queue, updates the appropriate pointers and updates NumberItems Write program code for Dequeue()[6]
  5. (e)(i)Write program code to extend the main program to call Dequeue() twice and output the return value each time.[2]
  6. (e)(ii)Test your program. Take a screenshot of the output(s). Copy and paste the screenshot into part 1(e)(ii) in the evidence document.[1]

Mark scheme

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

  1. [2] 1 mark each
  2. [2] • (global) Declaration of 1D array Queue, 20 elements initialised with -1
  3. [2] • (global) HeadPointer and TailPointer initialised to -1, NumberItems initialised with 0
  4. [6] 1 mark each
  5. [6] • Function header (and close) taking 1 (integer) parameter and returning a Boolean value in all cases
  6. [6] • Checking if queue is full (NumberItems = 20) and returning FALSE
  7. [6] • Checking if queue is empty (NumberItems = 0) then and updating TailPointer and HeadPointer appropriately
  8. [6] • Incrementing TailPointer and NumberItems in appropriate place ...
  9. [6] ... looping back to 0 for TailPointer if at end of structure
  10. [6] • Storing parameter in Queue[TailPointer] (after increment) and returning TRUE
  11. [3] 1 mark each
  12. [3] • Calling Enqueue () with 1 to 25 (inclusive) in order
  13. [3] • storing/using return value in selection ...outputting Successful with integer and outputting Unsuccessful with integer correctly
  14. [6] 1 mark each
  15. [6] • Dequeue() header (and close) and checking if queue is empty (NumberItems = 0) and returning -1
  16. [6] • Returning data at HeadPointer
  17. [6] • Incrementing HeadPointer ...
  18. [6] ... and catching if = 20 to return to 0
  19. [6] • Decrementing NumberItems
  20. [6] • Resetting HeadPointer and TailPointer when queue is empty
  21. [2] 1 mark each
  22. [2] • Calling Dequeue() twice
  23. [2] • outputting return value from both calls
  24. [1] 1 mark for output showing:
  25. [1] • 1 to 20 with Successful
  26. [1] 21 to 25 with Unsuccessful
  27. [1] 1 and 2 output

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, 20 marks.
Source
A-Level Computer Science, May/June 2025 Paper 4 Variant 1, question 1.

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