Flowcharts
An algorithm is a series of steps that solves a problem or carries out a task. Each step must be clear and precise, and the steps must be in a sensible order, so that anyone following them gets the same result. You can represent an algorithm as a flowchart, as pseudocode or as program code; the steps and their order stay the same.
Most algorithms take input, do something with it called processing, and produce output. For example, an algorithm for a school trip may take the number of students going as input, multiply that number by the cost per student, and output the total cost. In a flowchart, input and output steps use the input/output symbol, while calculations and other processing steps use the process symbol. The order of the symbols shows the order in which the steps happen.
Every algorithm, however long, can be built from three basic structures: sequence, selection and iteration (also called repetition).
| Structure | What it does | Example in the trip algorithm |
|---|---|---|
| Sequence | Carries out steps one after another in order. | Ask for the number of students, calculate the cost, then display the cost. |
| Selection | Chooses between different paths depending on a condition. | If more than 30 students go, book a larger coach; otherwise book a smaller coach. |
| Iteration | Repeats a section of the algorithm. | Ask for each student's name, one at a time, until every student has been recorded. |
Selection is about choosing a path, while iteration is about repeating steps. These three structures are enough to describe any algorithm, whether it is written for a person to follow or for a computer to run.
Edexcel GCSE Computer Science · Flowcharts
Edexcel GCSE Computer Science · Input Function