Document a simple algorithm using a structured English description, a flowchart or pseudocode

Published by Patrick Mutisya · 14 days ago

Cambridge A-Level Computer Science 9618 – Topic 9.2 Algorithms

9.2 Algorithms

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

  1. Start.
  2. Read the number of elements \$n\$.
  3. Read the first element and store it in max.
  4. Set a counter i = 2.
  5. Repeat while i ≤ n:

    • Read the next element into value.
    • If value > max then set max = value.
    • Increment i by 1.

  6. Output max as the largest number.
  7. 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

StepAction
1READ \$n\$
2READ \$value\$
3SET \$max \leftarrow value\$
4FOR \$i \leftarrow 2\$ TO \$n\$ DO
5  READ \$value\$
6  IF \$value > max\$ THEN \$max \leftarrow value\$
7END FOR
8OUTPUT \$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.