Skip to main content
A-LevelComputer ScienceData types and structures9618/42 · Oct/Nov 2022 · Q321 Marks

A program uses a linear queue to store up to 100 integers.

  1. (a)A 1D array, Queue, is used to store the data. The head pointer points to the first number stored in the queue and the tail pointer points to the next free space in the queue. Write program code to: • declare the global array Queue • declare the global variable head pointer and assign an appropriate initial value • declare the global variable tail pointer and assign an appropriate initial value. Save your program as Question3_N22. Copy and paste the program code into part 3(a) in the evidence document.[3]
  2. (b)The function Enqueue() takes an integer value as a parameter and stores it in the queue. It returns TRUE if the value was successfully stored and FALSE otherwise. Write program code for the function Enqueue(). Save your program. Copy and paste the program code into part 3(b) in the evidence document.[6]
  3. (c)The main program uses the Enqueue() function to store the numbers 1 to 20 (inclusive) in the queue, in ascending numerical order. The program should output 'Successful' if all numbers are successfully enqueued, and 'Unsuccessful' otherwise. Amend the main program by writing program code to perform this task. Save your program. Copy and paste the program code into part 3(c) in the evidence document.[4]
  4. (d)The following iterative pseudocode function calculates the total of all the values stored in the queue. FUNCTION IterativeOutput(Start: INTEGER) RETURNS INTEGER DECLARE Total : INTEGER Total <- 0 FOR Count <- Start - 1 TO HeadPointer STEP -1 Total <- Total + Queue[Count] NEXT Count RETURN Total ENDFUNCTION Rewrite the function as a recursive function using program code. Save your program. Copy and paste the program code into part 3(d) in the evidence document.[6]
  5. (e)(i)Amend the main program by writing program code to perform this task. Save your program. Copy and paste the program code into part 3(e)(i) in the evidence document.[1]
  6. (e)(ii)Test your program. Take a screenshot to show the output. Copy and paste the screenshot into part 3(e)(ii) in the evidence document.[1]

Mark scheme

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

  1. [3] 1 mark per point: 1D array with 100 (Integer) spaces head pointer declared initialised to appropriate value e.g. -1 tail pointer declared initialised to 0
  2. [6] 1 mark per point: Function header (and close where appropriate) with integer parameter Checking if queue full and returning false If not full adding parameter to queue at tail pointer ... incrementing tail pointer (after adding to queue) and returning true Changing head pointer to 0 if this is the first element in array
  3. [4] 1 mark per point: Looping 20 times using Enqueue() with each number 1 to 20 in ascending numerical order... and storing/using the return value based on return value, outputting "Successful" and "Unsuccessful" if all numbers are added
  4. [6] 1 mark per point: function call (and end where appropriate) taking a parameter checking if at start of queue//20 ... ...returning the last value in the queue (otherwise) adding return value to a total // adding value in queue before recursive call and using this in the recursive call recursive call with Start/pointer -1 returning the final total
  5. [1] 1 mark for calling function and outputting return value.
  6. [1] 1 mark for screenshot showing 210, for example: 210

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, Oct/Nov 2022 Paper 4 Variant 2, 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