Past-paper question · 2025 May-June · Paper 41 · Q1(b)

Question 1(b) 2025 · May-June · Paper 41 · 6 marks

Original past-paper question for 1(B)
Original past-paper question for 1(B)
Reveal official mark-scheme answer Official mark-scheme answer for 1(B)Official mark-scheme answer for 1(B)Official mark-scheme answer for 1(B)

Official answer for Question 1

Part (b)

Question 1

mark each

Question 6

  • Function header (and close) taking 1 (integer) parameter and returning a Boolean value in all cases
  • Checking if queue is full (NumberItems = 20) and returning FALSE
  • Checking if queue is empty (NumberItems = 0) then and updating TailPointer and HeadPointer appropriately
  • Incrementing TailPointer and NumberItems in appropriate place …
  • … looping back to 0 for TailPointer if at end of structure
  • Storing parameter in Queue[TailPointer] (after increment) and returning TRUE
✓
9618/41
✓
Cambridge International AS & A Level – Mark Scheme
✓
May/June 2025
✓
PUBLISHED
✓
Question
✓
Answer
✓
Marks
✓
Example program code:
✓
Python
✓
def Enqueue(InputData):
✓
global Queue
✓
global HeadPointer
✓
global TailPointer
✓
global NumberItems
✓
if NumberItems >= 20:
✓
return False
✓
if TailPointer <= -1:
✓
TailPointer = 0
✓
HeadPointer = 0
✓
Queue[TailPointer] = InputData
✓
else:
✓
TailPointer = TailPointer + 1
✓
if TailPointer == 20:
✓
TailPointer = 0
✓
Queue[TailPointer] = InputData
✓
NumberItems +=1
✓
return True
✓
VB.NET
✓
Function Enqueue(InputData)
✓
If NumberItems >= 20 Then
✓
Return False
✓
End If
✓
If TailPointer <= -1 Then
✓
TailPointer = 0
✓
HeadPointer = 0
✓
Queue(TailPointer) = InputData
✓
9618/41
✓
Cambridge International AS & A Level – Mark Scheme
✓
May/June 2025
✓
PUBLISHED
✓
Question
✓
Answer
✓
Marks
✓
Else
✓
TailPointer = TailPointer + 1
✓
If TailPointer = 20 Then
✓
TailPointer = 0
✓
End If
✓
Queue(TailPointer) = InputData
✓
End If
✓
NumberItems = NumberItems + 1
✓
Return True
✓
End Function
✓
Java
✓
public static Boolean Enqueue(Integer InputData){
✓
if(NumberItems >= 20){
✓
return false;
✓
}
✓
if(TailPointer <= -1){
✓
TailPointer = 0;
✓
HeadPointer = 0;
✓
Queue[TailPointer] = InputData;
✓
}else{
✓
TailPointer++;
✓
if(TailPointer == 20){
✓
TailPointer = 0;
✓
}
✓
Queue[TailPointer] = InputData;
✓
}
✓
NumberItems++;
✓
return true;
✓
}
✓
9618/41
✓
Cambridge International AS & A Level – Mark Scheme
✓
May/June 2025
✓
PUBLISHED
✓
Question
✓
Answer
✓
Marks

Mark scheme 9618_s25_ms_41.pdf →

Show text version of question

Question 1

Part (b)

Question 1

A program stores positive integers in a circular queue.

The queue is stored as a global 1D array of 20 integers with the identifier Queue. Each index is initialised with the data –1

The global variable HeadPointer, initialised to –1, points to the first element in the queue. The global variable TailPointer, initialised to –1, points to the last element in the queue. The global variable NumberItems, initialised to 0, stores the number of items in the queue.

Part (b)

The function Enqueue():

  • takes an integer as a parameter
  • checks if the queue is full
  • returns FALSE if the queue is full
  • stores the parameter in the next position in the queue and returns TRUE if the queue is
  • not full

  • updates the appropriate pointers and NumberItems

Write program code for Enqueue()

Save your program.

Copy and paste the program code into part 1(b) in the evidence document.

[6]

Question 3

Topic relevance

Why this question appears here

82% assigned-topic match · Programming › Structured programming

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_41.pdf

Keep practising this topic