TK Study

Software Engineering › Memorise › Pseudocode, flowcharts and diagram rules

Pseudocode, flowcharts and diagram rules

Course spec: Algorithms, Control structures, Subroutines, System and data modelling tools

Pseudocode rules

facts

Keywords in capitals — IF, ELSE, WHILE, FOR, REPEAT, BEGIN, END, RETURN.
Paired structure — For every BEGIN there is an END; for every IF there is an ENDIF; WHILE has ENDWHILE; FOR has NEXT; CASEWHERE has END CASE.
Indentation — Indent the body of every control structure so the structure is clear.
Subroutines by name — Refer to a subroutine by name in the mainline and show its logic in a separate algorithm with the same name (refinement).
Mainline — Start complex algorithms with a clear, uncluttered mainline that calls subroutines. Each subroutine is concise.
Subroutine, module, subprogram, procedure — Interchangeable terms. A function is a subroutine that returns a single value with RETURN.
Sequence, selection, repetition — The three basic control structures. Algorithms are combinations of them.

Control structures in HSC pseudocode

code

Binary selection —
IF condition THEN
    process 1
ELSE
    process 2
ENDIF
Multi-way selection (case) —
CASEWHERE expression evaluates to
    choice a: process a
    choice b: process b
    OTHERWISE: default process
END CASE
Nested IF —
IF condition A THEN
    process 1
ELSE
    IF condition B THEN
        process 2
    ELSE
        process 3
    ENDIF
ENDIF
Pre-test loop —
WHILE condition is true
    process
ENDWHILE
Post-test loop —
REPEAT
    process
UNTIL condition is true
Counted loop —
FOR variable = start TO finish STEP increment
    statements
NEXT variable
Pre-test v post-test — Pre-test (WHILE) checks first, so the body may run zero times. Post-test (REPEAT...UNTIL) runs the body at least once and loops until the condition becomes true.
Subroutine with parameters —
BEGIN AddNumbers
    FOR i = 1 TO 5
        Add (i, i + 1, sum)
        Display sum
    NEXT i
END AddNumbers

BEGIN Add (x, y, total)
    total = x + y
END Add (x, y, total)
Function with RETURN —
BEGIN Add (x, y)
    total = x + y
    RETURN total
END Add (x, y)

Worked pseudocode: RiskRating (2025 Q17 style)

code

Task —

Sum 10 array scores: more than 35 = High, less than 20 = Low, otherwise Medium. (Original pseudocode in HSC style, matches the 2025 MG requirements.)

BEGIN RiskRating
    SET total = 0
    FOR i = 1 TO 10
        total = total + scores[i]
    NEXT i
    IF total > 35 THEN
        rating = "High"
    ELSE
        IF total < 20 THEN
            rating = "Low"
        ELSE
            rating = "Medium"
        ENDIF
    ENDIF
    Display rating
END RiskRating
Marking tips (3 marks) — Loop through all 10 items; accumulate correctly; correct conditions with the right boundaries (35 and 20 themselves are Medium); display or return the result.
Other standard algorithms —
BEGIN FindLargest
    largest = list[1]
    FOR i = 2 TO length
        IF list[i] > largest THEN
            largest = list[i]
        ENDIF
    NEXT i
    Display largest
END FindLargest

Flowchart rules

facts

Direction — Read top to bottom and left to right, with arrowheads on the lines.
Terminator — Rounded shape marking Start and End.
Process — Rectangle for a step or calculation.
Input/output — Parallelogram for reading input or displaying output.
Decision — Diamond with one input and labelled outputs (Yes/No or True/False). Arrows from a decision symbol must be labelled to avoid ambiguity.
Subroutine — Commonly drawn as a rectangle with double side bars (predefined process; this is common convention, check the symbol key in the paper), with its logic drawn as a separate flowchart of the same name.
Standard structures only — Build flowcharts from sequence, selection and repetition only.
Common errors — No Start/End, unlabelled decision arrows, loops that never end, flowing upward without a loop.

Drawing rules: DFD, structure chart, storyboard, decision tree, class diagram, ERD

facts

DFD process — Circle, named with a verb phrase (e.g. Validate vote), and must have at least one input and one output.
DFD data store — A file or database (electronic or paper). Data moves between stores and processes only via a process, never directly to an external entity.
DFD external entity — Person/organisation/system outside the boundary that sends or receives data (e.g. Voter, Electoral Commission).
DFD flows — Labelled curved arrows with the name of the data (not the action).
Level 0 — One process for the whole system, external entities and labelled flows only. No data stores, no internal processes.
Level 1 consistency — Inputs and outputs of the level 0 diagram must still appear (balanced) when you break the process into sub-processes.
Structure chart — Top module = mainline; sub-modules below; empty circle = data passed; filled circle = flag; diamond = decision; curved arrow = repetition; refinement = separate chart named the same as the subroutine.
Storyboard — One frame per screen with the layout, content and links (arrows) between screens; annotate what each button does.
Decision tree — Show all possible combinations of decisions and resulting actions; each path ends in another decision or a final action; label branches with the conditions.
Class diagram — Three-part boxes (name, attributes, methods); inheritance arrow from child to parent; show relationships and multiplicities (e.g. a student studies 1 or more subjects; a subject has 0 or more students).
ERD (common convention) — Entities as boxes, relationship lines with crow's feet for 'many', primary and foreign keys marked.
UI drawing — Use labelled boxes for elements (heading, buttons, inputs, navigation), show consistent layout, readable fonts, contrast, and accessible features (alt text, large buttons).
Gantt chart — Named tasks, estimated duration for each, dependencies, a clear time scale with dates and milestones; update with actual v estimated times.
Process diary entries — Date, person, progress since last entry, tasks achieved, stumbling blocks and how managed, approaches for upcoming tasks, reflective comments, resources used.
Wiring diagram — Standard symbols (resistor, capacitor, diode, LED, lightbulb, switch, motor, speaker, voltage source, integrated circuit, amplifier); show both data and power paths; label any extra component.