Past-paper question · 2023 May-June · Paper 41 · Q3(b)(ii)

Question 3(b)(ii) 2023 · May-June · Paper 41 · 3 marks

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

Official answer for Question 3

Part (b)

(ii)

Question 1

mark each

Question 3

✓
Procedure header (and end where appropriate) with no parameter, checking if empty (AnimalTopPointer = 0) and
✓
returning empty string
✓
If not empty returning the top data item (AnimalTopPointer-1)
✓
… and decrementing AnimalTopPointer
✓
Example program code:
✓
Java
✓
public static String PopAnimal(){
✓
String ReturnData;
✓
if(AnimalTopPointer == 0){
✓
return "";
✓
}else{
✓
ReturnData = Animal[AnimalTopPointer - 1];
✓
AnimalTopPointer--;
✓
return ReturnData;
✓
}
✓
}
✓
VB.NET
✓
Function PopAnimal()
✓
Dim ReturnData As String
✓
If AnimalTopPointer = 0 Then
✓
Return ""
✓
Else
✓
ReturnData = Animal(AnimalTopPointer - 1)
✓
AnimalTopPointer = AnimalTopPointer - 1
✓
Return ReturnData
✓
End If
✓
End Function
✓
9618/41
✓
Cambridge International AS & A Level – Mark Scheme
✓
May/June 2023
✓
PUBLISHED
✓
Question
✓
Answer
✓
Marks

Mark scheme 9618_s23_ms_41.pdf →

Show text version of question

Question 3

Part (b)

(ii)

Question 3

A program implements two stacks using 1D arrays. One stack stores the names of colours. One

stack stores the names of animals.

(ii)

Study the pseudocode function PopAnimal():

FUNCTION PopAnimal() RETURNS STRING

DECLARE ReturnData : STRING

IF AnimalTopPointer = 0 THEN

RETURN ""

ELSE

ReturnData Animal[AnimalTopPointer - 1]

AnimalTopPointer AnimalTopPointer - 1

RETURN ReturnData

ENDIF

ENDFUNCTION

Write program code to declare the function PopAnimal()

Save your program.

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

[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_s23_qp_41.pdf

Keep practising this topic