A binary search is used to find the value 63 in this sorted list:
[4, 9, 15, 22, 28, 33, 41, 50, 56, 63, 70](a) List, in order, each value that is compared with 63 during the search. [3]
(b) Explain why a binary search could not be used on the list [22, 4, 70, 9, 41]. [1]
- (a) 33 (first value compared)(1)
- (a) 56(1)
- (a) 63 (and the search stops). Allow 33, 56, 70, 63 if the upper middle item is chosen consistently when there is an even number of items; max 2 marks if extra/incorrect values appear(1)
- (b) The list is not sorted / not in order (binary search needs ordered data to know which half to discard)(1)
- Answer: (a) 33, 56, 63 (b) the list is not sorted
- Examiner tip: Write down only the items actually compared, in order. Listing the halves of the list instead of the middle values loses marks.