Write correct pseudocode from a given structured English description.
1. What is Structured English?
Structured English is a semi‑formal way of describing an algorithm using plain English combined with a limited set of control‑flow keywords. It bridges the gap between natural language and formal pseudocode.
Uses simple, unambiguous statements.
Keywords are written in capital letters (e.g., IF, ELSE, FOR EACH).
Each step is on a separate line and indented to show nesting.
2. Typical Structured English Keywords
Structured English
Pseudocode Equivalent
IF … THEN … ELSE … END IF
if … then … else … endif
FOR EACH item IN list DO … END FOR
for each item in list do … endfor
WHILE condition DO … END WHILE
while condition do … endwhile
REPEAT … UNTIL condition
repeat … until condition
SET variable TO expression
variable ← expression
OUTPUT value
output value
3. Converting Structured English to Pseudocode – Step‑by‑Step
Identify the control‑flow constructs (IF, WHILE, FOR EACH, REPEAT).
Replace each keyword with its pseudocode counterpart (see the table above).
Remove redundant words such as “SET”, “TO”, “DO”, “END …”.
Introduce assignment symbols (←) for variable initialisation and updates.
Maintain indentation to reflect nesting levels.
Check that every opened block has a matching closing block (ENDIF, ENDFOR, ENDWHILE, ENDREPEAT).
4. Example Conversion
Structured English Description
SET total TO 0
FOR EACH number IN numbers DO
IF number MOD 2 = 0 THEN
SET total TO total + number
END IF
END FOR
OUTPUT total
Pseudocode
total ← 0
for each number in numbers do
if number mod 2 = 0 then
total ← total + number
endif
endfor
output total
Explanation
“SET … TO …” becomes the assignment operator “←”.
“FOR EACH … DO … END FOR” becomes “for each … do … endfor”.
“IF … THEN … END IF” becomes “if … then … endif”.
Mathematical operators (e.g., MOD) are kept unchanged.
5. Common Pseudocode Conventions for A‑Level
All keywords are written in lower case (e.g., if, while).
Indentation is usually two spaces per nesting level.
Use the arrow symbol “←” for assignment; if unavailable, write “=”.
Comments, if required, are prefixed by // or placed on a separate line.
6. Practice Question
Write pseudocode for the following structured English description:
SET max TO numbers[1]
FOR i FROM 2 TO LENGTH(numbers) DO
IF numbers[i] > max THEN
SET max TO numbers[i]
END IF
END FOR
OUTPUT max
Answer (pseudocode)
max ← numbers[1]
for i ← 2 to length(numbers) do
if numbers[i] > max then
max ← numbers[i]
endif
endfor
output max
7. Complexity Notation (Optional)
When analysing an algorithm, we often express its running time using Big‑O notation. For example, the linear search algorithm above runs in \$O(n)\$ time because it examines each element at most once.