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

A program uses a circular queue to store strings. The queue is created as a 1D array, QueueArray, with 10 string items. The following data is stored about the queue: • the head pointer initialised to 0 • the tail pointer initialised to 0 • the number of items in the queue initialised to 0.

  1. (a)Declare the array, head pointer, tail pointer and number of items. If you are writing in Python, include attribute declarations using comments. Save your program as Question3_J2022. Copy and paste the program code into part 3(a) in the evidence document.[2]
  2. (b)The function Enqueue is written in pseudocode. The function adds DataToAdd to the queue. It returns FALSE if the queue is full and returns TRUE if the item is added. The function is incomplete, there are five incomplete statements. FUNCTION Enqueue(BYREF QueueArray() : STRING, BYREF HeadPointer : INTEGER, BYREF TailPointer : INTEGER, NumberItems : INTEGER, DataToAdd : STRING) RETURNS BOOLEAN IF NumberItems = THEN RETURN ENDIF QueueArray[... DataToAdd IF TailPointer >= 9 THEN TailPointer ELSE TailPointer ← TailPointer + 1 ENDIF NumberItems ← NumberItems RETURN TRUE ENDFUNCTION Write program code for the function Enqueue(). Save your program. Copy and paste the program code into part 3(b) in the evidence document.[7]
  3. (c)The function Dequeue() returns "FALSE" if the queue is empty, or it returns the next data item in the queue. Write program code for the function Dequeue(). Save your program. Copy and paste the program code into part 3(c) in the evidence document.[6]
  4. (d)(i)Amend the main program to: • take as input 11 string values from the user • use the Enqueue () function to add each element to the queue • output an appropriate message to state whether each addition was successful, or not • call Dequeue() function twice and output the return value each time. Save your program. Copy and paste the program code into part 3(d)(i) in the evidence document.[5]
  5. (d)(ii)Test your program with the input data: "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" Take a screenshot to show the output. Copy and paste the screenshot into part 3(d)(ii) in the evidence document.[1]

Mark scheme

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

  1. [1] Declaring variables: head pointer, tail pointer and number of items all initialised as 0 (integer)
  2. [1] QueueArray declared as 1D array as string with 10 elements
  3. [1] function heading and end, dealing with ByRef parameters
  4. [1] IF NumberItems = 10 THEN
  5. [1] RETURN FALSE
  6. [1] QueueArray[TailPointer] ← DataToAdd
  7. [1] IF TailPointer >= 9 THEN TailPointer ← 0 ELSE TailPointer ← TailPointer + 1 ENDIF (or equivalent modulo arithmetic)
  8. [1] NumberItems ← NumberItems + 1
  9. [1] RETURN TRUE
  10. [1] Function header and end
  11. [1] checking if queue is empty ...
  12. [1] returning False
  13. [1] If not empty accessing and returning item at head pointer
  14. [1] incrementing head pointer ...
  15. [1] changing head pointer to 0 if it's more than 9 after incrementing
  16. [1] decrement number of items
  17. [1] Taking 11 inputs...
  18. [1] calling Enqueue with each of the 11 inputs ...
  19. [1] outputting an appropriate message if added or not added
  20. [1] Calling Dequeue twice
  21. [1] ... outputting return value each time
  22. [1] 1 mark for showing inputs and outputs: A - J input and successful. K input and unsuccessful. Output: A, B

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

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