Past-paper question · 2025 May-June · Paper 42 · Q1(c)

Question 1(c) 2025 · May-June · Paper 42 · 4 marks

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

Official answer for Question 1

Part (c)

Question 1

mark each

Question 4

  • Function header (and end where appropriate) and returning a value in all cases.
  • Checking if stack is empty and returning string "–1"
  • (Otherwise) Decrementing TopOfStack
  • Returning element in stack at TopOfStack before TopOfStack is decremented
✓
Example program code:
✓
Java
✓
public static String Pop(){
✓
if (TopOfStack == -1){
✓
return "-1";
✓
}else{
✓
String ReturnValue = Stack[TopOfStack];
✓
TopOfStack--;
✓
return ReturnValue;
✓
}
✓
}
✓
VB.NET
✓
Function Pop()
✓
If TopOfStack = -1 Then
✓
Pop = "-1"
✓
Else
✓
Pop = Stack(TopOfStack)
✓
TopOfStack = TopOfStack - 1
✓
End If
✓
End Function
✓
9618/42
✓
Cambridge International AS & A Level – Mark Scheme
✓
May/June 2025
✓
PUBLISHED
✓
Question
✓
Answer
✓
Marks
✓
Python
✓
def Pop():
✓
global Stack
✓
global TopOfStack
✓
if TopOfStack == -1:
✓
return "-1"
✓
else:
✓
ReturnValue = Stack[TopOfStack]
✓
TopOfStack -= 1
✓
return ReturnValue
✓
9618/42
✓
Cambridge International AS & A Level – Mark Scheme
✓
May/June 2025
✓
PUBLISHED
✓
Question
✓
Answer
✓
Marks

Mark scheme 9618_s25_ms_42.pdf →

Show text version of question

Question 1

Part (c)

Question 1

A program reads data from a text file and stores it in a stack. The stack Stack is stored as a 1D

array of up to 20 elements. The pointer TopOfStack stores the index of the last element stored in the stack.

Part (c)

The function Pop() returns the next item from the stack.

The function returns "–1" if the stack is empty.

Write program code for Pop()

Save your program.

Copy and paste the program code into part 1(c) 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_s25_qp_42.pdf

Keep practising this topic