2.1.2 Structure Chart (MT-L)
2.1.2 Structure Chart (MT-L)
2.1.2 Structure Chart (MT-L)
Syllabus Content:
2.1.2 Structure chart
use a structure chart to express the parameters passed between the various
modules/ procedures/functions which are part of the algorithm design
describe the purpose of a structure chart
construct a structure chart for a given problem
derive equivalent pseudocode from a structure chart
Structure charts:
An alternative approach to modular design is to choose the sub-tasks and then construct a
structure chart to show the interrelations between the modules. Each box of the structure chart
represents a module. Each level is a refinement of the level above.
A structure chart also shows the interface between modules, the variables. These variables are
referred to as 'parameters'.
Figure below shows a structure chart for a module that calculates the average of two numbers.
The top-level box is the name of the module, which is refined into the three subtasks of Level 1.
The input numbers (parameters Number1 and Number2) are passed into the 'Calculate
Average' sub-task and then the Average parameter is passed into the 'OUTPUT Average' sub-
task. The arrows show how the parameters are passed between the modules.
1
Paper 2. Sec 2.1.2) Built-in-Functions Computer Science 9608
with Majid Tahir
Answer:
Structure charts can also show control information: selection and repetition.
2
Paper 2. Sec 2.1.2) Built-in-Functions Computer Science 9608
with Majid Tahir
Structure chart for number-guessing game with only one guess allowed
Following an enquiry to the insurance company, the customer receives a quotation letter with
the price of the insurance.
A program is to be produced.
The structure chart below shows the modular design for this process:
3
Paper 2. Sec 2.1.2) Built-in-Functions Computer Science 9608
with Majid Tahir
4
Paper 2. Sec 2.1.2) Built-in-Functions Computer Science 9608
with Majid Tahir
Answer:
Answer:
5
Paper 2. Sec 2.1.2) Built-in-Functions Computer Science 9608
with Majid Tahir
Exam-style Questions
1 A random number generator is to be tested to see whether all numbers within the range
1 to 20 are generated equally frequently.
6
Paper 2. Sec 2.1.2) Built-in-Functions Computer Science 9608
with Majid Tahir
Answer:
7
Paper 2. Sec 2.1.2) Built-in-Functions Computer Science 9608
with Majid Tahir
CALL InitialiseTally(Tally)
RandomNumber ← GenerateRandomNumber(20)
ENDFOR
CALL OutputTally(Tally)
Reference:
Cambridge International AS & A level Computer Science Course book by Sylvia Langfield and Dave Duddell