Document a simple algorithm using a structured English description, a flowchart or pseudocode
9.2 Algorithms – Cambridge A-Level CS 9618
What is an Algorithm?
An algorithm is a step‑by‑step set of instructions that solves a problem or performs a task. Think of it like a recipe for baking a cake – you follow each step in order to get the final result.
Structured English Description
Structured English uses plain English with a few key words (IF, THEN, ELSE, WHILE, END) to describe the flow of an algorithm. It’s easier to read than raw code and helps you plan before coding.
START
INPUT number
IF number MOD 2 = 0 THEN
OUTPUT "Even"
ELSE
OUTPUT "Odd"
END IF
END
Flowchart Representation
Flowcharts use shapes to represent steps:
- Oval – Start/End
- Rectangle – Process / Action
- Diamond – Decision (Yes/No)
- Arrow – Flow direction
Below is a simple textual flowchart for checking if a number is even or odd.
[Start] → [Input number] → [Decision: number MOD 2 = 0?] ├─ Yes → [Output "Even"] → [End] └─ No → [Output "Odd"] → [End]
Pseudocode Example
Pseudocode is a mix of natural language and programming constructs. It’s less formal than real code but more precise than structured English.
Algorithm CheckEvenOdd
Input: integer n
Output: string result
Begin
If n mod 2 = 0 Then
result ← "Even"
Else
result ← "Odd"
End If
Print result
End
Algorithm in a Table
Tables can help you organise steps and conditions clearly.
| Step | Action | Decision |
|---|---|---|
| 1 | Input number n | |
| 2 | Check if n mod 2 = 0 | Yes → Step 3, No → Step 4 |
| 3 | Output "Even" | |
| 4 | Output "Odd" |
Analogy: The Algorithm as a Road Map
Imagine you’re planning a road trip. The algorithm is your road map:
- Start point – Where you begin (input).
- Road signs (decisions) – Tell you which direction to take.
- Road segments (processes) – The actions you perform.
- Destination (output) – The final result.
Just like a map, an algorithm must guide you from start to finish without getting lost.
Key Takeaways for the Exam
- Always include start and end points.
- Use clear decisions (IF/ELSE) and loops (WHILE).
- Show the flow of control – what happens next after each step.
- When writing pseudocode, keep it language‑agnostic but precise.
- Use tables or flowcharts to visualise complex logic.
Revision
Log in to practice.