Multiple choiceQuestion 1 · Recall
Loading…
By the end you can construct and interpret structure charts showing module decomposition and parameter passing, and explain the purpose and use of state-transition diagrams for documenting algorithm behaviour.
A structure chart (also called a hierarchy chart) shows the static structure of a program — how it breaks down into modules (procedures/functions) and how they call each other.
Elements:
Purpose:
Step-by-step:
Example: Calculate average of student marks
┌─────────────┐
│ MAIN │
└──────┬──────┘
│
┌────────────┼────────────┐
▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────┐
│GetMarks │ │ CalcAvg │ │Display │
└────┬─────┘ └────┬─────┘ └────┬─────┘
│ │ │
marks[]↑ marks[]↓ avg↑
avg↑
GetMarks returns marks[] (output, by reference ↑)CalcAvg receives marks[] (input, by value ↓), returns avg (output ↑)Display receives avg (input ↓)Deriving pseudocode from a structure chart:
Worked example: Structure chart to pseudocode — grade calculator
Structure chart: MAIN calls GetScore (returns score), Validate (score → returns validFlag), CalculateGrade (score → returns grade), DisplayResult (grade)
A state-transition diagram (state machine diagram) shows the dynamic behaviour of an algorithm or system — how it moves between states in response to events/inputs.
Elements:
event [guard] / action
Purpose (per syllabus):
Worked example: State-transition diagram — PIN entry system
A system allows up to 3 PIN attempts. Correct PIN → success. Wrong PIN → retry. 3 wrong → locked.