Past-paper question · 2021 May-June · Paper 43 · Q4(b)(iii)

Question 4(b)(iii) 2021 · May-June · Paper 43 · 6 marks

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

Official answer for Question 4

Part (b)

(iii)

Question 1

mark per bullet point

Question 6

  • Outputting the data in the root node
  • Check if left Pointer is/is not –1 …
  • … recursive call left with left pointer as parameter, if not –1
  • Check if right Pointer is/is not –1 …
  • … recursive call right with right pointer as parameter, if not −1
  • Output, left, right in correct order with
✓
Example code:
✓
PROCEDURE preOrder(rootpointer)
✓
OUTPUT(binaryTree[rootPointer].Data)
✓
IF binaryTree[rootPointer].leftPointer <> -1
✓
THEN
✓
preOrder(binaryTree[rootPointer].LeftPointer)
✓
ENDIF
✓
IF binaryTree[rootPointer].rightPointer <> -1
✓
THEN
✓
preOrder(binaryTree[rootPointer].rightPointer)
✓
ENDIF
✓
ENDPROCEDURE
✓
9608/43
✓
Cambridge International AS & A Level – Mark Scheme
✓
May/June 2021
✓
PUBLISHED
✓
Question
✓
Answer
✓
Marks

Mark scheme 9608_s21_ms_43.pdf →

Show text version of question

Question 4

Part (b)

(iii)

Question 4

Chon creates a binary tree structure to store options that the user can select from a menu (M) in

his program.

M

C
R
A
G L W

Each node in the binary tree is stored using the following record structure:

TYPE node

leftPointer : INTEGER

data : STRING

rightPointer : INTEGER

ENDTYPE

The tree is stored as a 1D array, binaryTree. Null pointers are represented by –1.

(iii)

A pre-order traversal on the following tree would output M C A G R L W

M

C
R
A
G L W

The pre-order traversal can be written as a recursive procedure:

1. output the root node 2. follow the left pointer and repeat from step 1 3. follow the right pointer and repeat from step 1.

Complete the pseudocode recursive procedure preOrder().

PROCEDURE preOrder(BYVALUE rootPointer : INTEGER)

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

Question 13

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

ENDPROCEDURE

[6]

Question 14

Topic relevance

Why this question appears here

98% assigned-topic match · Computational thinking and problem-solving › Recursion

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 9608_s21_qp_43.pdf

Keep practising this topic