By the end of this lesson students will be able to:
CASE statements, comments).Problem (system) decomposition is the systematic breaking‑down of a complex problem or system into a set of smaller, more manageable sub‑systems (or sub‑tasks). Each sub‑system performs a single, well‑defined function, can be designed and coded independently, and is later combined to form the complete solution. In the Cambridge syllabus this is also called top‑down design or divide‑and‑conquer.
| PDLC stage | Corresponding decomposition step | Typical artefact |
|---|---|---|
| Analysis | Step 1 – Analyse the whole problem | Problem statement, list of inputs/outputs, validation checks |
| Design | Steps 2‑5 – Identify sub‑systems, break into sub‑tasks, define interfaces, arrange order | Structured pseudo‑code, top‑down flowchart, interface table (see Section 4) |
| Coding | Implementation of each sub‑task as a procedure/function or module | Source code (Python, Java, etc.) following Cambridge pseudo‑code style |
| Testing | Step 6 – Validate & verify | Test data set, trace tables, error‑identification report |
When you translate a decomposition into pseudo‑code you will need the following Cambridge constructs:
READ and OUTPUT statements (parallelogram symbols in flowcharts).IF … THEN … END IF and CASE … OF … END CASE for multi‑way decisions.FOR … TO … DO … END FOR and WHILE … DO … END WHILE.OPEN, READ FROM, WRITE TO, CLOSE.Given a list of n integer marks, output the highest and lowest mark. Each mark must be between 0 and 100.
MARKS[ ].MAX ← MARKS[0] and MIN ← MARKS[0].MAX and MIN.MAX and MIN.| Sub‑system | Inputs | Outputs | Data type / notes |
|---|---|---|---|
| Input | none (keyboard) | n, MARKS[0…n‑1] |
INTEGER, INTEGER ARRAY |
| Initialise | MARKS[0] |
MAX, MIN |
INTEGER |
| Validate | MARKS[0…n‑1] |
none (or programme stops) | INTEGER, range 0‑100 |
| Process | MARKS[1…n‑1], MAX, MIN |
updated MAX, MIN |
INTEGER |
| Output | MAX, MIN |
displayed values | INTEGER |
01 DECLARE n, i, MAX, MIN : INTEGER 02 DECLARE MARKS[ ] : ARRAY[0..99] OF INTEGER // max 100 marks 03 04 READ n 05 FOR i ← 0 TO n‑1 DO 06 READ MARKS[i] 07 END FOR 08 09 // ---- Validation ------------------------------------------------- 10 FOR i ← 0 TO n‑1 DO 11 IF MARKS[i] < 0 OR MARKS[i] > 100 THEN 12 OUTPUT "Invalid mark at position", i 13 STOP 14 END IF 15 END FOR 16 17 // ---- Initialise ------------------------------------------------- 18 MAX ← MARKS[0] 19 MIN ← MARKS[0] 20 21 // ---- Process ---------------------------------------------------- 22 FOR i ← 1 TO n‑1 DO 23 IF MARKS[i] > MAX THEN 24 MAX ← MARKS[i] 25 END IF 26 IF MARKS[i] < MIN THEN 27 MIN ← MARKS[i] 28 END IF 29 END FOR 30 31 // ---- Output ----------------------------------------------------- 32 OUTPUT "Highest mark :", MAX 33 OUTPUT "Lowest mark :", MIN
Process sub‑system, recording i, MARKS[i], MAX and MIN after each iteration.> vs. >=).MAX / MIN.| i | MARKS[i] | MAX (after step) | MIN (after step) |
|---|---|---|---|
| 0 | 73 | 73 | 73 |
| 1 | 85 | 85 | 73 |
| 2 | 60 | 85 | 60 |
| 3 | 92 | 92 | 60 |
| 4 | 58 | 92 | 58 |
Consider the validation condition “mark ≥ 50 AND mark ≤ 100”.
(mark ≥ 50) ∧ (mark ≤ 100).| mark ≥ 50 | mark ≤ 100 | Result (AND) |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
| Pitfall | Consequence | Remedy |
|---|---|---|
| Too many tiny sub‑tasks | Unnecessary overhead; overall flow becomes hard to follow | Stop dividing when a sub‑task can be expressed in ≤ 3 pseudo‑code lines. |
| Overlapping responsibilities | Duplicate work; data‑flow errors | Give each sub‑system a single, clear purpose and list its interface. |
| Missing or ambiguous interfaces | Incorrect data passed between modules | Complete an interface table (inputs, outputs, data types, pre‑conditions) for every sub‑task. |
| Skipping validation/verification | Programme crashes or produces wrong results | Include validation checks in the analysis stage; verify with trace tables and test data. |
| Off‑by‑one errors in loops | Missing or extra iteration; wrong results | Check loop limits carefully; use trace tables to confirm the first and last iteration. |
SELECT mark FROM marks WHERE student_id = …). The same decomposition principles apply – the database query becomes a separate sub‑system with its own interface.| Step | What to do | Output / artefact |
|---|---|---|
| 1 | Analyse the specification (AO1) | List of inputs, required outputs, constraints, validation checks |
| 2 | Identify major sub‑systems (AO2) | High‑level task list (e.g., Input, Initialise, Validate, Process, Output) |
| 3 | Break sub‑systems into sub‑tasks (AO2) | Detailed sub‑task list, each ≤ 3 pseudo‑code lines |
| 4 | Define interfaces for every sub‑task (AO2) | Interface table (inputs, outputs, data types, pre‑conditions) |
| 5 | Arrange execution order & draw a top‑down flowchart (AO2) | Flowchart or ordered pseudo‑code using Cambridge symbols |
| 6 | Validate, verify and test the complete algorithm (AO3) | Test data set, trace tables, error‑identification report, evaluation of solution |
[42, 17, 93, 5].
FOR i ← 0 TO n‑2 DO
FOR j ← 0 TO n‑i‑2 DO
IF A[j] > A[j+1] THEN
TEMP ← A[j]
A[j] ← A[j+1]
A[j+1] ← TEMP
END IF
END FOR
END FOR
n = 4, marks = [55, 70, 68, 82]n = 3, marks = [0, 100, 50]n = 2, marks = [‑5, 105] – show how the validation check stops the programme.A top‑down flowchart showing the main problem at the top, branching into the five sub‑systems (Input, Initialise, Validate, Process, Output). The Process block contains a loop (rectangle) with a decision diamond for the “max/min” comparisons. Use the standard Cambridge symbols: parallelogram (input/output), rectangle (process), diamond (decision), arrows for flow.
Create an account or Login to take a Quiz
Log in to suggest improvements to this note.
Your generous donation helps us continue providing free Cambridge IGCSE & A-Level resources, past papers, syllabus notes, revision questions, and high-quality online tutoring to students across Kenya.