Question 2(e)(i) 2024 · October-November · Paper 42 · 5 marks
Question 2
Part (e)
(i)
Question 2
A linear queue data structure is designed using a record structure.
The record structure Queue has the following fields:
- QueueArray, a 1D array of up to 100 integer values
- Headpointer, a variable that stores the index of the first data item in QueueArray
- Tailpointer, a variable that stores the index of the next free location in QueueArray.
(i)
The main program asks the user to enter 10 integers with values of 0 or greater. It reads
each input repeatedly until a valid number is entered.
All 10 valid inputs are added to the queue, using Enqueue().
If the value returned from Enqueue() is –1, a message is output to state that the queue is full, otherwise a message is output to state that the item has been added to the queue.
The function ReturnAllData() is called once all 10 integers have been entered and the return value from the function call is output.
Amend the main program to perform these actions.
Save your program.
Copy and paste the program code into part 2(e)(i) in the evidence document.
Reveal official mark-scheme answer
Official answer for Question 2
Part (e)
(i)
Question 1
mark each
Question 5
- Taking only 10 inputs in loop/one at a time
- Calling Enqueue() with each input (min) and storing/using return value …
- … only calling Enqueue() once when each input is an integer = 0. Do not award if this validation stops 10 valid
- Outputting message if each item is inserted and outputting a message if queue is full
- Calling ReturnAllData() and outputting return value at the end
Why this question appears here
72% assigned-topic match · Hardware › Logic gates and logic circuits
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_w24_qp_42.pdf
