Question 1(d) 2025 · May-June · Paper 43 · 6 marks
Reveal official mark-scheme answer


Official answer for Question 1
Part (d)
Question 1
mark each
Question 6
- CreateQueue() header (and end) and opening the file to read and closing file in appropriate place
- Looping until end of file
- Reading in each/all lines (and converting to integer and removing new line)
- … calling Enqueue() once with each value …
- … checking return value and outputting "Queue full" if full (can output once or many times)
- Exception try, catch with appropriate output. All file access within try
Show text version of question
Question 1
Part (d)
Question 1
A program reads data from a text file and stores it in a queue. The linear queue Queue is stored as
a 1D array of up to 50 elements. The queue has the following pointers:
- HeadPointer – this stores the index of the first element in the queue, initialised to –1
- TailPointer – this stores the index of the last element in the queue, initialised to –1
Part (d)
The text file QueueData.txt stores positive integers. Each integer is on a new line in the
file.
The procedure CreateQueue():
- opens the file QueueData.txt
- reads in each line from the text file and uses Enqueue() to insert each line into the
- outputs "Queue full" if any item cannot be inserted into the queue
- uses exception handling when opening and reading from the text file.
queue
The procedure needs to work for a file that contains an unknown number of lines.
Write program code for CreateQueue()
Save your program.
Copy and paste the program code into part 1(d) in the evidence document.
Why this question appears here
71% assigned-topic match · Programming › Constructs
Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.
Permanent source page: Educate A Change · From 9618_s25_qp_43.pdf
