Question 5(c)(i) 2013 · October-November · Paper 32 · 1 mark
Reveal official mark-scheme answer
Official answer for Question 5
Part (c)
(i)
Part (c)
(i)
Items in order
Show text version of question
Question 5
Part (c)
(i)
Question 5
Customer names are stored in the array Customer. For
Examiner's Use An algorithm is to be designed to perform a serial search of the array for a requested customer name.
The algorithm will use the variables shown in the table.
Examiner's Use
(i)
What condition is put on the Customer array for a binary search to be used?
The following recursive function is for the binary search algorithm.
FUNCTION BinarySearch(ThisArray, FindValue, Low, High) : INTEGER IF High < Low THEN RETURN -1 // not found ELSE Middle ← INT((High + Low) / 2) IF ThisArray[Middle] > FindValue THEN BinarySearch(ThisArray, FindValue, Low, Middle – 1) ELSE IF (ThisArray[Middle] < FindValue) THEN BinarySearch(ThisArray, FindValue, Middle + 1, High) ELSE RETURN Middle // found ENDIF ENDIF ENDIF ENDFUNCTION
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 9691_w13_qp_32.pdf
