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

Question 4(c) 2015 · October-November · Paper 32 · 6 marks

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

Official answer for Question 4

Part (c)

Part (c)

(i)

//binary tree search

✓
INPUT SearchFood
✓
IsFound ← FALSE
[1]
✓
Current ← RootPtr
[1]
✓
REPEAT
✓
IF Food[Current] = SearchFood
[1]
✓
THEN
✓
//found
✓
OUTPUT "Found"
✓
ISFound ← TRUE
[1]
✓
ELSE
✓
IF SearchFood < Food[Current]
✓
THEN
✓
// move left
✓
Current ← LeftPtr[Current]
✓
ELSE
✓
Current ← RightPtr[Current]
[1]
✓
ENDIF
✓
ENDIF
✓
UNTIL IsFound = TRUE OR
✓
Current = 0/Null/-1/Unassigned
[1]
✓
IF IsFound = FALSE
✓
THEN
✓
OUTPUT SearchFood, "Not Found"
✓
ENDIF

Mark scheme 9691_w15_ms_32.pdf →

Show text version of question

Question 4

Part (c)

An algorithm is designed in pseudocode to search the binary tree for a particular food name. The algorithm uses the additional variables below: Variable Data type Description SearchFood STRING Food name to search for Current INTEGER The array subscript for the item currently considered IsFound BOOLEAN Flags to TRUE when SearchFood is found Complete the algorithm below: //binary tree search INPUT SearchFood IsFound ← ............................................................................................................................ Current ← ............................................................................................................................ REPEAT IF Food[Current] = ...................................................................................................... THEN //found OUTPUT "Found" ....................................................................................................................................... ELSE IF SearchFood < Food[Current] THEN // move left Current ← LeftPtr[Current] ELSE ............................................................................................................................... ENDIF ENDIF UNTIL IsFound = TRUE OR ............................................................................................... IF IsFound = FALSE THEN OUTPUT SearchFood "Not Found" ENDIF

[6]

Question 13

Topic relevance

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_32.pdf

Keep practising this topic