What Is an Algorithm? Flow Charts, Pseudocode and Trace Tables | OCR A Level Further Maths notes
Free preview: What Is an Algorithm? Flow Charts, Pseudocode and Trace Tables
What Is an Algorithm?
Year 1 (AS) for OCR B (MEI). For Edexcel and OCR A, check your own specification for which parts are AS and which are A level.
Let's start with something you already do. When you add two long numbers in columns, you follow the same steps every time: add the units, carry if needed, move left. You don't have to think about why. You just follow the steps. That list of steps is an algorithm.
- An algorithm is a finite list of precise instructions that solves a problem.
- Follow the steps exactly and you always reach an answer, even if you do not understand why the steps work.
- That is why computers can run algorithms: no judgement is needed, only following orders.
- Decision Mathematics is about algorithms for real problems: sorting lists, packing boxes, finding shortest routes, planning projects.
Why do we need such strict rules?
Imagine a recipe that says "add some salt and cook until it looks right". Two cooks will get two different meals. A computer can't do it at all, because it doesn't know what "looks right" means. An algorithm removes every bit of guesswork, so anyone (or any machine) following it gets the same answer.
What makes a good algorithm?
| Property | What it means | Example of breaking it |
|---|---|---|
| Precise | Each instruction has exactly one meaning. | "Add a bit more" is not allowed; "add 3 to x" is. |
| Finite | It must stop after a finite number of steps. A loop needs a condition that will eventually be met. | "Keep adding 1 to x until x is negative", starting from x = 5, never stops. |
| Input and output | It takes some data in (the input) and gives a result (the output). | A list of steps that never outputs anything solves nothing. |
| General | It works for every valid input, not just one example. | A method that only works when x = 6 is a calculation, not an algorithm. |
Three ways to write an algorithm
- In words, as numbered steps: "Step 3: if x is even, go to Step 5".
- In pseudocode: a halfway house between words and a programming language, such as "Let c = c + 1" or "If x = 1 then output c".
- As a flow chart: boxes joined by arrows, with a different shape for each kind of instruction (next page).
All three can describe exactly the same algorithm. They are just different handwriting for the same recipe.
The most important line in pseudocode: Let c = c + 1
- Notice that "Let c = c + 1" is not an equation. It means "work out c + 1, then store the answer as the new c".
- A variable is a named storage box. The instruction changes what is in the box.

What the picture shows
- Think of c as a labelled box. At the start the box holds 3.
- First read the box and work out the right-hand side: .
- Then store the 4 in the box. The old 3 is thrown away, so c now holds 4.
- Read as an equation, would give , which is impossible. That is how you know it is an instruction.
๐ก In plain words
- An algorithm is a recipe so exact that a machine could follow it.
- "Let x = (something)" means: work out the something using the old values, then overwrite x.
๐ Right vs wrong: order matters
- Start with a = 2, b = 5. Then "Let a = b", then "Let b = a".
- Wrong: thinking the values swap, giving a = 5, b = 2.
- Right: after "Let a = b", a is 5. Then "Let b = a" copies that 5 into b. Both are now 5. The 2 is lost for ever.
- To swap two variables you need a spare box: Let t = a, let a = b, let b = t.
โ๏ธ YOUR TURN 1
Try this first:
Start with x = 4 and y = 7. Carry out these instructions in order. What are x and y at the end?
- Let x = x + y
- Let y = x โ y
- Let x = x โ y
Answer:
- Step 1: x = 4 + 7 = 11 (y is still 7).
- Step 2: y = 11 โ 7 = 4 (uses the new x).
- Step 3: x = 11 โ 4 = 7 (uses the new x and the new y).
- End: x = 7, y = 4. The three steps swap x and y without a spare box. Neat!
Flow Charts: An Algorithm Drawn as a Map
A list of steps with lots of "go to Step 2" instructions can be hard to follow. A flow chart draws the same thing as a map: you follow arrows, and the route splits at each question.

Following the diagram
- The rounded boxes are start and stop. Every flow chart has one start.
- Rectangles are instructions: do them and follow the single arrow out.
- Diamonds are decisions: a yes/no question with two arrows out, labelled Yes and No.
- The arrow from "Let c = c + 1" goes back up to "Is x = 1?". That is a loop: the same boxes run again and again.
- The loop ends only when the answer to "Is x = 1?" is Yes. Then c is output and the algorithm stops.
| Shape | Meaning | Arrows out |
|---|---|---|
| Rounded box | Start or stop | One (start) or none (stop) |
| Rectangle | Instruction: do something, such as Let c = 0 | Exactly one |
| Diamond | Decision: a yes/no question | Two, labelled Yes and No |
How to trace a flow chart (the recipe)
- Put your finger on Start. Why: every run begins in the same place.
- At a rectangle, do the instruction and write the new value down. Why: values change, and you will forget them if you keep them in your head.
- At a diamond, answer the question using the current values, then follow the Yes or No arrow. Why: the route depends on the values right now, not earlier ones.
- When an arrow takes you back up, carry on from there. Why: that is the loop running again.
- Stop only at a Stop box, and write down what was output.
Unlock the full note: start 7 days free.
Log in or subscribe to read the rest of this note. Members also get the AI tutor, practice quizzes, mock exams and flashcards for this topic.
Log in ยท Subscribe ยท Start free trial
All notes in Algorithms, Complexity, Sorting and Bin Packing
- What Is an Algorithm? Flow Charts, Pseudocode and Trace Tables
- Bubble Sort, Shuttle Sort and Quick Sort Step by Step
- Bin Packing: Lower Bounds, First Fit, First Fit Decreasing and Full Bins
- The Order of an Algorithm: Counting Comparisons and Predicting Run Times
What's inside for this topic
4 teacher notes, 80 practice questions, 52 flashcards, 2 quizzes.
Get the full notes, every practice question, flashcards, quizzes and mock papers.
Next note: Bubble Sort, Shuttle Sort and Quick Sort Step by Step
All OCR A Level Further Maths topics ยท A Level Further Maths