Question 3(d) 2022 · October-November · Paper 43 · 7 marks
Question 3
Part (d)
Question 3
A binary tree consists of nodes. Each node has 3 integer values: a left pointer, data and a right
pointer.
The binary tree is stored using a global 2D array.
The pseudocode declaration for the array is:
DECLARE ArrayNodes : ARRAY[0:19, 0:2] OF INTEGER
For example:
- ArrayNodes[0, 0] stores the left pointer for the first node.
- ArrayNodes[0, 1] stores the data for the first node.
- ArrayNodes[0, 2] stores the right pointer for the first node.
- 1 indicates a null pointer, or null data.
Part (d)
A post order traversal performs the following operation:
- visit the left node
- visit the right node
- output the root.
For example, in the following tree, the output would be: 3 9 25 60 50
Question 50
25 60 3 9 An outline of the PostOrder() procedure is:
- If left node is not empty, make a recursive call with the left node as the root.
- If right node is not empty, make a recursive call with the right node as the root.
- Output the current root node.
The procedure PostOrder() takes the root node as a parameter.
Write program code for the procedure PostOrder().
Save your program.
Copy and paste the program code into part 3(d) in the evidence document.
Question 11
Reveal official mark-scheme answer
Official answer for Question 3
Part (d)
Question 1
mark per point (Max 7):
Question 7
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 9618_w22_qp_43.pdf
