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

A program reads data from the user and stores the data that is valid in a linear queue. The queue is stored as a global 1D array, QueueData, of string values. The array needs space for 20 elements. The global variable QueueHead stores the index of the first element in the queue. The global variable QueueTail stores the index of the last element in the queue.

  1. (a)The main program initialises all the elements in QueueData to a suitable null value, QueueHead to -1 and QueueTail to -1. Write program code for the main program.[1]
  2. (b)The function Enqueue() takes the data to insert into the queue as a parameter. If the queue is not full, it inserts the parameter in the queue, updates the appropriate pointer(s) and returns TRUE. If the queue is full, it returns FALSE. Write program code for Enqueue().[4]
  3. (c)The function Dequeue() returns "false" if the queue is empty. If the queue is not empty, it returns the next item in the queue and updates the appropriate pointer(s). Write program code for Dequeue().[3]
  4. (d)(i)The subroutine StoreItems() takes ten 7-character strings as input from the user and uses the check digit to validate each input. Each valid input has the check digit removed and is stored in the queue using Enqueue(). An appropriate message is output if the item is inserted. An appropriate message is output if the queue is already full. Invalid inputs are not stored in the queue. The subroutine counts and outputs the number of invalid items that were entered. StoreItems () can be a procedure or a function as appropriate. Write program code for StoreItems().[6]
  5. (d)(ii)Write program code to amend the main program to: • call StoreItems() • call Dequeue() • output a suitable message if the queue was empty • output the returned value if the queue was not empty.[1]
  6. (d)(iii)Test the program with the following inputs in the order given: 999999X 1251484 5500212 0033585 9845788 6666666 3258746 8111022 7568557 0012353 Take a screenshot of the output(s).[2]

Mark scheme

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

  1. [1] 1 mark each • QueueData as 1D (string) array initialised to 20 null values and QueueHead initialised to -1, QueueTail initialised to -1
  2. [4] 1 mark each • Function header (and end) taking one parameter and returns a Boolean value in all instances • Checks if queue is full and returns FALSE • (If not full) Inserts data item to QueueTail + 1 and increments QueueTail and returns TRUE • Assigns QueueHead to 0 when first element is entered (this can come from incrementing)
  3. [3] 1 mark each • Dequeue function header (and end) returning a string in all cases • Check if queue is empty and return "false" • (otherwise) remove value at QueueHead and increment QueueHead and return value from array
  4. [6] 1 mark each to max 6 • StoreItems header (function/procedure and end where appropriate) and takes 10 inputsi • Input is split and first 6 characters used in calculation (as integers) ... • ... multiplication by 1 and 3 alternately, adding to total, dividing by 10, rounding down/cast int ... • ... comparing check digit to character in position 6 • ... including comparison of X for 10 • Calling Enqueue with first 6 characters when valid • outputting appropriate message on return (for both inserted and queue full) • Counts and outputs number of invalid inputs
  5. [1] • Calling StoreItems() and Dequeue() once and outputting a suitable message if the queue was empty and outputting the returned value if the queue was not empty
  6. [2] 1 mark each • Data input of 10 values and output a message saying there are 4 invalid items • 999999 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, 17 marks.
Source
A-Level Computer Science, May/June 2024 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