An efficient algorithm solves a problem using as few resources as possible. At GCSE the two key resources are:
AQA focuses primarily on time efficiency. You need to compare two algorithms and explain which uses fewer steps.
For a list of 1,000,000 items, an inefficient algorithm might need 1,000,000 steps to find an item; an efficient one might need only 20 steps. As datasets grow, efficiency becomes critical.
| Algorithm | Best case | Worst case | Requirement |
|---|---|---|---|
| Linear search | 1 comparison | n comparisons | Works on any list |
| Binary search | 1 comparison | log₂(n) comparisons | List must be sorted |
For n = 1,000: linear search needs up to 1,000 comparisons; binary search needs at most 10 (log₂(1000) ≈ 10).
For n = 1,000,000: linear search → up to 1,000,000; binary search → at most 20.
| Algorithm | Comparisons (worst case) | Memory | Complexity |
|---|---|---|---|
| Bubble sort | ~n² (e.g. 1,000 items → 1,000,000) | In-place (no extra) | Simple |
| Merge sort | ~n × log₂(n) (e.g. 1,000 items → 10,000) | Extra space needed | More complex |
For 1,000 items, merge sort uses approximately 100× fewer comparisons than bubble sort.
| Factor | Consideration |
|---|---|
| Input size | Small list → bubble sort is fine. Large list → use merge sort or binary search. |
| Whether data is sorted | Binary search requires sorted data. Linear search works on any list. |
| Memory available | Merge sort needs extra memory. Bubble sort is in-place. |
| Frequency | An algorithm run billions of times needs to be as efficient as possible. |
Two algorithms can produce the same correct result but differ in how many steps they take.
8 AQA-style questions · 22 marks · AI marks your answers and gives feedback
| Term | Definition |
|---|
Timed exam conditions. No feedback until you submit.