This section demonstrates how to document a simple algorithm using three common techniques:
Structured English description
Flowchart (illustrated with a suggested diagram placeholder)
Pseudocode
Example Problem
Find the maximum value in a list of \$n\$ positive integers.
1. Structured English Description
Start.
Read the number of elements \$n\$.
Read the first element and store it in max.
Set a counter i = 2.
Repeat while i ≤ n:
Read the next element into value.
If value > max then set max = value.
Increment i by 1.
Output max as the largest number.
Stop.
2. Flowchart
The flowchart below outlines the same steps. Replace the placeholder with an actual diagram when creating teaching material.
Suggested diagram: Flowchart showing start → input \$n\$ → input first value → set max → loop (input value → compare → update max → increment i) → output max → stop.
3. Pseudocode
Step
Action
1
READ \$n\$
2
READ \$value\$
3
SET \$max \leftarrow value\$
4
FOR \$i \leftarrow 2\$ TO \$n\$ DO
5
READ \$value\$
6
IF \$value > max\$ THEN \$max \leftarrow value\$
7
END FOR
8
OUTPUT \$max\$
Key Points for Documentation
Use clear, unambiguous language in Structured English.
Flowcharts should have standard symbols: oval (Start/Stop), parallelogram (Input/Output), rectangle (Process), diamond (Decision).
Pseudocode must be consistent in indentation and use mathematical notation where appropriate (e.g., \$<\$, \$>\$, \$\leq\$).
Always include a brief description of the algorithm’s purpose and its input/output specifications.