Past-paper question · 2015 October-November · Paper 43 · Q4(c)(i)

Question 4(c)(i) 2015 · October-November · Paper 43 · 5 marks

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

Official answer for Question 4

Part (c)

(i)

Part (c)

(i)

01 PROCEDURE TraverseTree(BYVALUE Root : INTEGER)

✓
02
✓
IF Tree[Root].LeftPointer < > 0
✓
03
✓
THEN
✓
04
✓
TraverseTree(Tree[Root].LeftPointer)
✓
05
✓
ENDIF
✓
06
✓
OUTPUT Tree[Root].Name
✓
07
✓
IF Tree[Root].RightPointer < > 0
✓
08
✓
THEN
✓
09
✓
TraverseTree(Tree[Root].RightPointer)

Question 10

✓
ENDIF
✓
11 ENDPROCEDURE
[5]

Mark scheme 9608_w15_ms_43.pdf →

Show text version of question

Question 4

Part (c)

(i)

Question 4

A binary tree Abstract Data Type (ADT) has these associated operations:

  • create the tree (CreateTree)
  • add an item to tree (Add)
  • output items in ascending order (TraverseTree)
A
programmer needs an algorithm for outputting items in ascending order. To design this, the

programmer writes a recursive procedure in pseudocode.

(i)

Complete the pseudocode:

01 PROCEDURE TraverseTree(BYVALUE Root: INTEGER)

02 IF Tree[Root].LeftPointer .................................................................

03 THEN

04 TraverseTree( .............................................................................)

05 ENDIF

06 OUTPUT .............................................................................................. .Name

07 IF ........................................................................................................ <> 0

08 THEN

09 TraverseTree( .............................................................................)

10 ENDIF

11 ENDPROCEDURE

[5]
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_w15_qp_43.pdf

Keep practising this topic