What is the difference between an algorithm and a program?
Based on: AQA 8525 · 3.1.1
Section 3.1 is examined on Paper 1. You need to be able to trace a simple algorithm by hand, work out its purpose, and compare how efficiently two algorithms solve the same problem. The facts below are the ones those tasks depend on.
What is the difference between an algorithm and a program?
Based on: AQA 8525 · 3.1.1
Which condition must be true before a binary search can be used?
Based on: AQA 8525 · 3.1.3
What does decomposition mean when solving a problem?
Based on: AQA 8525 · 3.1.1
In a flowchart, which shape is used for a decision?
Based on: AQA 8525 · 3.1.1
An algorithm is a sequence of steps that solves a problem. A program is that sequence written in a language a computer can run. The same algorithm can be coded in Python, C# or VB.NET and it is still the same algorithm. Two skills sit underneath this. Decomposition breaks a problem into smaller sub-problems that can be solved on their own. Abstraction removes the detail that does not matter so you can concentrate on what does. A timetable app that ignores the colour of each train is using abstraction, because the colour has no bearing on when the train departs.
Pseudo-code, program code and flowcharts. Pseudo-code is not a real language and does not have to run. Any exam question that gives you pseudo-code uses AQA's standard version, so you need to read it fluently, and the question tells you which form your answer should take. A flowchart uses fixed shapes joined by arrows, and a decision diamond has one arrow out for each possible answer. Tracing an algorithm, also called a dry run, means working through it by hand, step by step, and recording how the values of the variables change, for example in a trace table. If the question gives you input values, use exactly those.
A linear search checks each item in turn from the start until it finds the target or runs out of items. It works on unordered data. A binary search looks at the middle item and, if that is not the target, throws away the half the target cannot be in. It only works on data that is already sorted. On large lists binary search is much faster, because each comparison halves what is left. A linear search on 1,000 items may need 1,000 comparisons. A binary search needs at most about 10. On a very short list, or on data that would have to be sorted first, a linear search can still win.
A bubble sort passes through the list repeatedly, comparing neighbouring pairs and swapping them if they are the wrong way round. After the first pass the largest value is in its final place. It can stop early if a whole pass makes no swaps, because that means the list is already sorted. A merge sort splits the list in half over and over until every part holds one item, then merges pairs of parts back together in order. Merge sort is faster than bubble sort on large lists. It needs extra memory to hold the parts while merging, so bubble sort can be preferred when memory is tight and the list is small.
Efficiency here is about how the time an algorithm needs grows as the amount of data grows. It is not about how fast one particular computer is. Two algorithms can produce the same output and still differ in efficiency. When a question asks you to compare them it wants the number of steps or comparisons, not a preference. Standard algorithms are worth memorising as patterns: find the maximum, find the minimum, count how many items match a condition, and total or average an array.
| Linear search | Binary search |
|---|---|
| Checks each item in turn from the start. | Checks the middle item and discards the half the target cannot be in. |
| Works on unordered data. | Only works on data that is already sorted. |
| On 1,000 items it may need 1,000 comparisons. | On 1,000 items it needs at most about 10. |
| Can be the quicker choice on a very short list, or when the data would have to be sorted first. | Usually needs far fewer comparisons on a large sorted list, because each comparison halves what is left. |
No. It only works on data that is already sorted. On unsorted data it can discard the half that holds the target.
Decomposition breaks a problem into smaller sub-problems that can be solved separately. Abstraction removes detail that does not affect the problem. They are different skills and the exam tests whether you can tell them apart.
Not necessarily. After one pass of a sort into ascending order, only the largest value is guaranteed to be in its final place. The sort keeps passing until a whole pass makes no swaps.
It is faster than bubble sort on large lists, but it needs extra memory to hold the parts while merging. When memory is tight and the list is small, bubble sort can be preferred.
Describe the purpose in one sentence, for example it finds the largest value in the array, rather than retelling the code line by line.
RiverMap Learning apps are independent study tools. They are not affiliated with, endorsed by, or connected to any government body or examination authority. Question content is original and based on publicly available official study materials.