Easy1 markShort Answer
AQA GCSE · Question 12.3 · Fundamentals of algorithms
State why a binary search cannot be used on the list fruits.
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
Q01.1Figure 1 shows an algorithm, represented using pseudo-code, which assigns a different value to fo...EasyQ01.2The variable `x` is assigned a value using the statement:
`x ← LEN(state)`
Using Figure 1, what ...EasyQ01.3What is the result of concatenating the contents of the variables `city` and `landmark` in Figure 1?EasyQ01.5The subroutine `POSITION` finds the first position of a character in a string.
For example, `POSI...EasyQ02.1Figure 2 shows an algorithm that uses integer division which has been represented using pseudo-co...Easy
Expert