Algorithms in pseudocode/flowcharts
A Systematic Approach to Problem Solving
Before writing any code, a good programmer follows a structured series of steps. This systematic approach ensures the problem is fully understood before any solution is attempted, reducing errors and wasted effort.
- Understand the problem - read carefully and identify exactly what needs to be solved.
- Identify inputs and outputs - what data goes in, and what result must come out?
- Design the algorithm - plan the step-by-step logic before writing any code.
- Represent the algorithm - write it as pseudocode, a flowchart, or program code.
- Test the solution - trace through the algorithm with example data to verify it works correctly.
This process separates thinking from typing - designing the algorithm properly first makes the programming stage much more straightforward.
Three Ways to Represent an Algorithm
AQA requires algorithms to be represented in three forms: pseudocode, flowcharts, and program code. Each form serves a different purpose but describes the same underlying logic. The example below uses a simple problem - "ask the user for a number, then output double that number" - to show all three representations.
Pseudocode uses structured English-like keywords to describe an algorithm without worrying about any specific programming language. AQA uses a standard pseudocode format - keywords such as INPUT, OUTPUT, and the assignment arrow ← are always written the same way.
INPUT number result ← number * 2 OUTPUT result
This pseudocode is language-neutral - it could be implemented in Python, C#, VB.NET, or any other language without changing the logic.
Flowcharts represent an algorithm visually using standard symbols connected by arrows. Each symbol has a specific meaning:
- Oval - Start or End
- Parallelogram - Input or Output
- Rectangle - Process (e.g. a calculation)
- Diamond - Decision (a yes/no question)
[Flowchart diagram to be inserted here]
Program code is the implementation of the algorithm in a real programming language. The logic is identical to the pseudocode - only the syntax changes. AQA supports Python, VB.NET, and C#.
The same algorithm implemented in Python:
number = int(input()) result = number * 2 print(result)
Notice that the three lines of pseudocode map directly to three lines of program code. This is the value of designing in pseudocode first.
Key Takeaways
- A systematic approach means understanding the problem and designing an algorithm before writing any code.
- Always identify inputs and outputs as the first step in algorithm design.
- Pseudocode uses structured English-like keywords and is language-neutral - AQA uses a standard format.
- Flowcharts represent the same logic visually, using standard symbols (oval, rectangle, parallelogram, diamond).
- Program code is the implementation of the algorithm in a real language - the logic should match the pseudocode exactly.
- All three representations describe the same underlying algorithm - only the notation differs.