Use a structure chart to decompose a problem into sub-tasks and express the parameters passed between the various modules/procedures/functions which are part of the algorithm design

Published by Patrick Mutisya · 8 days ago

Cambridge A-Level Computer Science 9618 – Programme Design: Structure Charts

12.2 Programme Design

Learning Objective

Use a structure chart to decompose a problem into sub‑tasks and express the parameters passed between the various modules, procedures or functions that form part of the algorithm design.

What is a Structure Chart?

A structure chart is a hierarchical diagram that shows how a program is broken down into modules and how data flows between them. It helps to:

  • Identify logical sub‑tasks.
  • Define clear interfaces (parameters) for each module.
  • Promote top‑down design and modular programming.

Steps to Create a Structure Chart

  1. Analyse the problem statement. Identify the main goal and any sub‑goals.
  2. Define the top‑level module. This is usually the main routine that coordinates the whole solution.
  3. Decompose the top‑level module. Break it into logical sub‑modules until each module is small enough to be coded easily (typically 10–20 lines of code).
  4. Identify data items. Determine which data each module needs to receive (input parameters) and what it returns (output parameters).
  5. Draw the chart. Use rectangles for modules and arrows to show parameter flow. The chart is read from top (high‑level) to bottom (low‑level).
  6. Validate the design. Check that every required data item is passed exactly once and that no module has unnecessary dependencies.

Parameter Types

When specifying parameters, distinguish between:

  • Input parameters – values supplied to a module.
  • Output parameters – values returned to the calling module.
  • In‑out parameters – values that are both read and modified.

Illustrative Example

Problem: Calculate the final grade for a class of students. Each student has marks for three assessments, each weighted differently. The final grade is the weighted sum, rounded to the nearest integer, and then classified as A, B, C, D or F.

Suggested diagram: Structure chart showing modules Main, ReadData, ComputeWeightedSum, RoundResult, ClassifyGrade, OutputResult.

Decomposition into Modules

ModulePurposeInput ParametersOutput Parameters
MainCoordinates overall processing.
ReadDataRead number of students and their three assessment marks.students[ ][3] (array of marks), n (number of students)
ComputeWeightedSumCalculate \$S = w1 m1 + w2 m2 + w3 m3\$ for each student.marks[3], weights[3]rawScore (real)
RoundResultRound the raw score to the nearest integer.rawScore (real)roundedScore (integer)
ClassifyGradeMap the rounded score to a grade letter.roundedScore (integer)grade (char)
OutputResultDisplay each student's final grade.studentID, grade

Parameter Flow Example

For a single student, the data flow is:

  1. ReadData supplies marks[3] to ComputeWeightedSum.
  2. ComputeWeightedSum returns rawScore to RoundResult.
  3. RoundResult returns roundedScore to ClassifyGrade.
  4. ClassifyGrade returns grade to OutputResult.

Key Points to Remember

  • Each module should have a single, well‑defined purpose.
  • Parameters should be as small as possible – pass only what is needed.
  • Use meaningful names for modules and parameters to improve readability.
  • Top‑down design encourages testing of high‑level logic before low‑level details.
  • When drawing the structure chart, keep the hierarchy clear: parent modules above child modules.

Practice Exercise

Design a structure chart for the following problem and complete the parameter table:

“A library system must allow a user to search for a book by title, check its availability, and if available, issue the book to the user. The system must also update the inventory and record the transaction.”

Guidelines:

  1. Identify the top‑level module (e.g., ProcessLoan).
  2. Break it into sub‑modules such as SearchBook, CheckAvailability, IssueBook, UpdateInventory, RecordTransaction.
  3. Specify the input and output parameters for each module.

When you have completed the chart, compare it with the example above to ensure consistency in style and parameter notation.