Easy1 markShort Answer
Fundamentals of algorithmsGeneralalgorithmsbinary search

AQA GCSE · Question 12.3 · Fundamentals of algorithms

State why a binary search cannot be used on the list fruits.

How to approach this question

Recall the main pre-requisite for a binary search algorithm. A binary search works by repeatedly dividing the search interval in half. This method only works if the list is in a specific order.

Full Answer

The list is not sorted.
A binary search algorithm requires the list (or array) to be sorted. It works by comparing the target value to the middle element of the list. If the target is smaller, it searches the left half; if larger, it searches the right half. This process of elimination is only possible because the sorted nature of the list guarantees which half the target must be in. The `fruits` list `["banana", "apple", ...]` is not in alphabetical order, so a binary search would not work correctly.

Common mistakes

✗ Giving a vague answer like "it wouldn't work".\n✗ Confusing the requirements of binary search with linear search.

Practice the full AQA GCSE Computer Science Paper 1 Python

31 questions · hints · full answers · grading

More questions from this exam