Question 5(c) 2015 · October-November · Paper 31 · 6 marks
Reveal official mark-scheme answer
Official answer for Question 5
Part (c)
Part (c)
//binary tree search
Show text version of question
Question 5
Part (c)
An algorithm is designed in pseudocode to search the binary tree for a particular city. The algorithm uses the additional variables below: Variable Data type Description SearchCity STRING City to search for Current INTEGER The array subscript for the item currently considered IsFound BOOLEAN Flags to TRUE when SearchCity is found Complete the algorithm below: // binary tree search INPUT ................................................................................................................................ IsFound ← FALSE Current ← RootPtr REPEAT IF City[Current] = ............................................................................................. THEN // found OUTPUT "Found" ........................................................................................................................ ELSE IF SearchCity > City[Current] THEN // move right ........................................................................................................... ELSE Current ← LeftPtr[Current] ENDIF ENDIF UNTIL Current = 0 OR ............................................................................................... IF ..................................................................................................................................... THEN OUTPUT SearchCity "Not Found" ENDIF
Question 13
Why this question appears here
72% assigned-topic match · Data types and structures › Data types and records
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 9691_w15_qp_31.pdf
