Question 2(c) 2024 · October-November · Paper 42 · 5 marks
Question 2
Part (c)
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.
Part (c)
The pseudocode function Enqueue() inserts an integer value into the queue.
The function is incomplete. There are three incomplete statements.
FUNCTION Enqueue(BYREF AQueue : Queue, BYVAL TheData : INTEGER) RETURNS INTEGER
IF AQueue.Headpointer = -1 THEN
AQueue.QueueArray[AQueue.Tailpointer] ← ........................................ AQueue.Headpointer ←0 AQueue.Tailpointer ← AQueue.Tailpointer + 1
RETURN 1
ELSE
IF AQueue.Tailpointer > ........................................ THEN
RETURN -1
ELSE
AQueue.QueueArray[AQueue.Tailpointer] ← TheData AQueue.Tailpointer ← AQueue.Tailpointer ........................................ RETURN 1
ENDIF
ENDIF
ENDFUNCTION
Write program code for Enqueue().
Save your program.
Copy and paste the program code into part 2(c) in the evidence document.
Reveal official mark-scheme answer
Official answer for Question 2
Part (c)
Question 1
mark for each completed statement to max 3
Question 5
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_w24_qp_42.pdf
