Past-paper question · 2025 October-November · Paper 41 · Q1(d)

Question 1(d) 2025 · October-November · Paper 41 · 4 marks

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

Official answer for Question 1

Part (d)

Question 1

mark each

Question 4

  • Looping 40 times
  • Generating random number between 0 and 1000 inclusive inside the loop
  • Calling Push() with each random number and storing/using return value … … if return value is FALSE output Stack
✓
full and breaking out of loop
✓
Example program code
✓
Java
✓
for(Integer X = 0; X < 40; X++){
✓
Pushed = Push(RandomNumber.nextInt(1001));
✓
if(Pushed == false){
✓
System.out.println("Stack full");
✓
X = 40;
✓
}
✓
}
✓
VB.NET
✓
For x = 0 To 39
✓
Pushed = Push(RandomNumber.Next(0, 1000))
✓
If Pushed = False Then
✓
Console.WriteLine("Stack full")
✓
x = 40
✓
End If
✓
Next
✓
Python
✓
for x in range(40):
✓
Pushed = Push(random.randint(0,1000))
✓
if Pushed == False:
✓
print("Stack full")
✓
break
✓
9618/41
✓
Cambridge International AS & A Level – Mark Scheme
✓
October/November 2025
✓
PUBLISHED
✓
Question
✓
Answer
✓
Marks

Mark scheme 9618_w25_ms_41.pdf →

Show text version of question

Question 1

Part (d)

Question 1

A program stores integers in a stack. The stack is represented as a 1D array of 30 elements with

the identifier Stack

The global pointer TopOfStack stores the index of the last element inserted into the stack. TopOfStack is initialised to –1

Part (d)

The main program generates 40 random integers between 0 and 1000 (inclusive) and attempts

to insert each one into the stack using the appropriate function. If the return value from the function call indicates the stack is full, no more integers are generated and "Stack full" is output.

Write program code for the main program.

Save your program.

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

[4]
Topic relevance

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

Keep practising this topic