What is an algorithm?
Finite, ordered, unambiguous, executable, terminating.
An algorithm is a step-by-step procedure for solving a class of problems. To count as an algorithm, the procedure must be:
- Finite — has a defined ending.
- Ordered — steps are performed in a specified sequence.
- Unambiguous — each step has a single, clear interpretation.
- Executable — each step can be performed in finite time.
- Terminating — finishes after a finite number of steps (no infinite loops).
Two ways to express an algorithm in D1:
Pseudocode — structured English. Example:
INPUT N
SET A = 1
FOR k = 1 TO N
A = A * k
NEXT k
OUTPUT A
Flowchart — diagrammatic. Standard shapes:
- Rounded rectangle: START / STOP.
- Parallelogram: INPUT / OUTPUT.
- Rectangle: process / assignment.
- Diamond: decision (yes/no branch).
Trace table. When asked to 'execute' or 'trace' an algorithm for a given input, build a table with one row per loop iteration and a column for each variable. Edexcel mark schemes split M and A marks across the rows — partial tables forfeit multiple marks.
Worked example. Trace the factorial pseudocode above with .
| at start | at end | ||
|---|---|---|---|
| 1 | 1 | 1 | |
| 2 | 1 | 2 | |
| 3 | 2 | 6 | |
| 4 | 6 | 24 |
Output .
- Algorithm = finite, ordered, unambiguous, executable, terminating.
- Pseudocode = structured English; flowchart = diagram.
- Decision (diamond) = yes/no branch.
- Trace table = one row per iteration, one column per variable.