Topic 7 · Algorithm Design and Problem-Solving
Develop, represent, test, trace, correct, and explain algorithms using the exact methods required by Paper 2.
8 lesson sections · 8 worked applications · Paper 2 · Cambridge 0478 (2026–2028)
Variables, conditions, loops, tables, and step-by-step reasoning.
Dry-run in execution order. Precision matters: write the actual condition or correction, not a vague natural-language substitute.
Program Development Life Cycle
The defining description of analysis stage is “identifies the problem, requirements, abstraction, and decomposition needed.” Connect it with design stage, whose role is “plans the solution using decomposition, structure diagrams, flowcharts, or pseudocode.”
Required vocabulary and boundaries
| Idea | Precise role | Evidence or example |
|---|---|---|
| analysis stage | identifies the problem, requirements, abstraction, and decomposition needed | listing required inputs, outputs, and constraints |
| design stage | plans the solution using decomposition, structure diagrams, flowcharts, or pseudocode | drawing the modules before coding |
| coding stage | implements the designed solution as program code | writing the planned selection and loops |
| iterative testing during coding | runs and checks developing sections so errors can be found early | testing a completed input module |
| testing stage | uses planned test data to check whether the completed program meets requirements | running normal and boundary cases |
| life-cycle connection | uses outputs from earlier stages to guide later implementation and testing | test cases trace back to analysed requirements |
Four-step exam routine
Identify the exact clue and name analysis stage only when its defining role fits.
State the mechanism or boundary: plans the solution using decomposition, structure diagrams, flowcharts, or pseudocode.
Apply the idea to evidence such as “writing the planned selection and loops.”
Reject the tempting error that waits until every possible feature is finished before any execution.
Reason Before Naming
The PDLC reduces wasted coding by checking requirements and design before implementation.
Start by underlining the clue in the scenario, then decide what job that clue is describing. This keeps the answer tied to the concept being assessed.
Design comes before coding because the developer plans the algorithm, interface, and data before writing source code.
| Scenario clue | What it proves |
|---|---|
| unclear requirements | analysis |
| algorithm plan needed | design |
| program instructions needed | coding |
| errors suspected | testing |
| released system changes | maintenance |
When The Scenario Is Less Obvious
The question may include a boundary case or a tempting wrong answer. Use the exact role in the scenario as evidence.
- analysis: finding out what the program must do
- design: planning the solution before coding
- coding: writing the program instructions
- testing: checking whether the program works correctly
- maintenance: fixing or improving the program after release
A strong answer names the stage and links it to the evidence in the scenario.
| Term | Use in this lesson |
|---|---|
| analysis | finding out what the program must do |
| design | planning the solution before coding |
| coding | writing the program instructions |
| testing | checking whether the program works correctly |
| maintenance | fixing or improving the program after release |
A Common Mix-Up
A common mistake is mixing up design and coding.
Fix: Use the action clue: gather, plan, write, test, or change after release.
| Mistake | Correction |
|---|---|
| A common mistake is mixing up design and coding. | Use the action clue: gather, plan, write, test, or change after release. |
Abstraction and Decomposition
The defining description of abstraction is “keeps relevant details and removes information that does not affect the solution.” Connect it with decomposition, whose role is “breaks a problem or system into smaller manageable parts.”
Required vocabulary and boundaries
| Idea | Precise role | Evidence or example |
|---|---|---|
| abstraction | keeps relevant details and removes information that does not affect the solution | recording journey time but not a driver's favourite colour |
| decomposition | breaks a problem or system into smaller manageable parts | separating login, booking, and payment subsystems |
| subsystem hierarchy | recognises that a system contains subsystems that can contain further subsystems | payment contains validation and receipt modules |
| input component | identifies the data entering a solution or subsystem | a user enters a product code |
| process and storage components | describe transformations and retained data needed by the solution | calculate a total and store an order record |
| output component | identifies the information or action produced by a solution | displaying a receipt total |
Four-step exam routine
Identify the exact clue and name abstraction only when its defining role fits.
State the mechanism or boundary: breaks a problem or system into smaller manageable parts.
Apply the idea to evidence such as “payment contains validation and receipt modules.”
Reject the tempting error that is the result produced after processing.
Reason Before Naming
Large programming problems become easier when irrelevant detail is removed and the remaining work is split into modules.
Start by underlining the clue in the scenario, then decide what job that clue is describing. This keeps the answer tied to the concept being assessed.
Decomposition breaks a booking system into smaller modules such as login, search, booking, cancellation, and reports.
| Scenario clue | What it proves |
|---|---|
| too much irrelevant detail | abstraction |
| problem too large | decomposition |
| show module hierarchy | structure chart |
When The Scenario Is Less Obvious
The question may include a boundary case or a tempting wrong answer. Use the exact role in the scenario as evidence.
- abstraction: removing unnecessary detail
- decomposition: breaking a problem into smaller sub-problems
- module: separate part of a larger solution
- structure chart: diagram showing a system broken into modules
A strong answer names the technique and describes the exact detail or sub-task.
| Term | Use in this lesson |
|---|---|
| abstraction | removing unnecessary detail |
| decomposition | breaking a problem into smaller sub-problems |
| module | separate part of a larger solution |
| structure chart | diagram showing a system broken into modules |
A Common Mix-Up
A common mistake is swapping abstraction and decomposition.
Fix: Ask: are we ignoring detail or breaking the problem into smaller tasks?
| Mistake | Correction |
|---|---|
| A common mistake is swapping abstraction and decomposition. | Ask: are we ignoring detail or breaking the problem into smaller tasks? |
Algorithm Construction
The defining description of algorithm is “is a precise ordered set of steps that solves a problem.” Connect it with algorithm purpose, whose role is “states the overall result the algorithm is intended to achieve.”
Required vocabulary and boundaries
| Idea | Precise role | Evidence or example |
|---|---|---|
| algorithm | is a precise ordered set of steps that solves a problem | instructions for finding a maximum value |
| algorithm purpose | states the overall result the algorithm is intended to achieve | find and output the largest mark |
| algorithm process description | explains how inputs, decisions, repetition, and outputs produce the result | compare each value and update Maximum |
| pseudocode design | expresses language-independent solution steps using the required examination conventions | IF Value > Maximum THEN |
| flowchart design | uses standard symbols and directed flow to show algorithm steps | a decision diamond for a condition |
| algorithm precision | writes exact conditions and operations that can be followed without guessing | X > Y instead of 'X is greater' |
Four-step exam routine
Identify the exact clue and name algorithm only when its defining role fits.
State the mechanism or boundary: states the overall result the algorithm is intended to achieve.
Apply the idea to evidence such as “compare each value and update Maximum.”
Reject the tempting error that requires a specific programming-language library.
Reason Before Naming
A small line placement error can change the whole result of an algorithm.
Start by underlining the clue in the scenario, then decide what job that clue is describing. This keeps the answer tied to the concept being assessed.
A pass counter starts at 0 and increases by 1 only when the score meets the pass condition.
| Scenario clue | What it proves |
|---|---|
| before loop | initialise |
| inside loop | process each value |
| IF condition | selection |
| NEXT/ENDWHILE | close loop |
When The Scenario Is Less Obvious
The question may include a boundary case or a tempting wrong answer. Use the exact role in the scenario as evidence.
- algorithm: step-by-step solution
- pseudocode: structured English-like algorithm notation
- flowchart: diagram showing algorithm steps
- counter: variable used for counting
- accumulator: variable used for a running total
A strong answer explains why a line is needed, not just what the line says.
| Term | Use in this lesson |
|---|---|
| algorithm | step-by-step solution |
| pseudocode | structured English-like algorithm notation |
| flowchart | diagram showing algorithm steps |
| counter | variable used for counting |
| accumulator | variable used for a running total |
A Common Mix-Up
A common mistake is using an accumulator without initialising it.
Fix: Check initialisation, loop bounds, condition, and update position.
| Mistake | Correction |
|---|---|
| A common mistake is using an accumulator without initialising it. | Check initialisation, loop bounds, condition, and update position. |
Sorting and Searching
The defining description of linear search is “checks items one by one until the target is found or the data ends.” Connect it with linear-search result, whose role is “records whether or where the target was found.”
Required vocabulary and boundaries
| Idea | Precise role | Evidence or example |
|---|---|---|
| linear search | checks items one by one until the target is found or the data ends | compare a name with each array element |
| linear-search result | records whether or where the target was found | Found becomes TRUE at the matching index |
| bubble sort | repeatedly compares adjacent items and swaps those in the wrong order | swap 9 and 4 when sorting ascending |
| bubble-sort pass | moves through adjacent pairs so a large unsorted value can move toward the end | one complete left-to-right set of comparisons |
| bubble-sort repetition | continues passes until no further swaps are needed or the required passes finish | a Swap flag remains FALSE |
| method distinction | uses linear search to locate a target and bubble sort to reorder data | find a product versus arrange prices |
Four-step exam routine
Identify the exact clue and name linear search only when its defining role fits.
State the mechanism or boundary: records whether or where the target was found.
Apply the idea to evidence such as “swap 9 and 4 when sorting ascending.”
Reject the tempting error that guarantees every list is sorted after one comparison.
Reason Before Naming
The algorithm choice depends on the task: locating data is different from ordering data.
Start by underlining the clue in the scenario, then decide what job that clue is describing. This keeps the answer tied to the concept being assessed.
Bubble sort compares adjacent items and swaps them if they are in the wrong order.
| Scenario clue | What it proves |
|---|---|
| target value | linear search |
| unsorted list | linear search still works |
| neighbour comparison | bubble sort |
| prevent data loss | temporary variable |
When The Scenario Is Less Obvious
The question may include a boundary case or a tempting wrong answer. Use the exact role in the scenario as evidence.
- linear search: checking list items one by one
- bubble sort: sorting by repeatedly comparing adjacent items
- swap: exchange two values
- temporary variable: extra storage used during a swap
A strong answer names the algorithm and describes the repeated operation.
| Term | Use in this lesson |
|---|---|
| linear search | checking list items one by one |
| bubble sort | sorting by repeatedly comparing adjacent items |
| swap | exchange two values |
| temporary variable | extra storage used during a swap |
A Common Mix-Up
A common mistake is saying linear search requires the list to be sorted.
Fix: For searching, track checked items. For sorting, track adjacent comparisons and swaps.
| Mistake | Correction |
|---|---|
| A common mistake is saying linear search requires the list to be sorted. | For searching, track checked items. For sorting, track adjacent comparisons and swaps. |
Validation and Verification
The defining description of input validation is “checks that input is sensible and follows defined rules.” Connect it with range check and length check, whose role is “test numeric limits or the permitted number of characters.”
Required vocabulary and boundaries
| Idea | Precise role | Evidence or example |
|---|---|---|
| input validation | checks that input is sensible and follows defined rules | a mark must be from 0 to 100 |
| range check and length check | test numeric limits or the permitted number of characters | age 0–120 or an eight-character identifier |
| type check and presence check | test whether input has the required data type or has been supplied | an integer quantity and a non-empty surname |
| format check and check digit | test a required pattern or a calculated digit | DD/MM/YYYY or a valid product code |
| visual check | has a person compare entered data with the original source | checking a typed address against a form |
| double entry check | requires the same data to be entered twice and compares the entries | typing a new password twice |
Four-step exam routine
Identify the exact clue and name input validation only when its defining role fits.
State the mechanism or boundary: test numeric limits or the permitted number of characters.
Apply the idea to evidence such as “an integer quantity and a non-empty surname.”
Reject the tempting error that guarantee the real-world value is true.
Reason Before Naming
A value can be valid but still wrong, so validation and verification can both be needed.
Start by underlining the clue in the scenario, then decide what job that clue is describing. This keeps the answer tied to the concept being assessed.
Verification checks copied data against the original, for example by double entry or visual checking.
| Scenario clue | What it proves |
|---|---|
| must be 1 to 12 | range check |
| must not be empty | presence check |
| must match pattern | format check |
| typed from paper | verification |
When The Scenario Is Less Obvious
The question may include a boundary case or a tempting wrong answer. Use the exact role in the scenario as evidence.
- validation: automatic check that data is sensible or allowed
- verification: check that copied data matches the source
- range check: checks data is within limits
- presence check: checks data is not blank
- double entry: entering data twice to compare copies
A strong answer says what is being checked and why that makes it validation or verification.
| Term | Use in this lesson |
|---|---|
| validation | automatic check that data is sensible or allowed |
| verification | check that copied data matches the source |
| range check | checks data is within limits |
| presence check | checks data is not blank |
| double entry | entering data twice to compare copies |
A Common Mix-Up
A common mistake is saying validation proves data is correct.
Fix: Use validation for sensible/allowed; use verification for matching the source.
| Mistake | Correction |
|---|---|
| A common mistake is saying validation proves data is correct. | Use validation for sensible/allowed; use verification for matching the source. |
Test Data and Trace Tables
The defining description of normal test data is “is valid, typical input within the accepted range.” Connect it with abnormal test data, whose role is “is invalid input that should be rejected.”
Required vocabulary and boundaries
| Idea | Precise role | Evidence or example |
|---|---|---|
| normal test data | is valid, typical input within the accepted range | 50 for a permitted mark of 0–100 |
| abnormal test data | is invalid input that should be rejected | −4 for a permitted mark of 0–100 |
| extreme test data | is the largest or smallest acceptable value | 0 and 100 for a mark range |
| boundary test data | includes each extreme accepted value and the corresponding value just outside the boundary | −1, 0, 100, and 101 |
| trace table dry run | documents changing values step by step during execution | columns for Count, Total, and Maximum |
| trace-table outputs and prompts | records displayed output and user prompts at the steps where they occur | showing 'Enter mark' before an INPUT |
Four-step exam routine
Identify the exact clue and name normal test data only when its defining role fits.
State the mechanism or boundary: is invalid input that should be rejected.
Apply the idea to evidence such as “0 and 100 for a mark range.”
Reject the tempting error that contains only one typical middle value.
Reason Before Naming
Boundary values are important because many errors happen just inside or outside the allowed limits.
Start by underlining the clue in the scenario, then decide what job that clue is describing. This keeps the answer tied to the concept being assessed.
A trace table is completed by dry-running the algorithm and recording variable values when they change.
| Scenario clue | What it proves |
|---|---|
| middle valid value | normal |
| minimum/maximum valid | boundary |
| outside valid range | abnormal |
| step through variables | trace table |
When The Scenario Is Less Obvious
The question may include a boundary case or a tempting wrong answer. Use the exact role in the scenario as evidence.
- normal test data: valid data the program should accept
- boundary test data: data at the edge of valid limits
- abnormal test data: invalid data the program should reject
- trace table: table recording variable values during a dry run
- dry run: manually stepping through an algorithm
A strong answer uses the exact limits and shows the variable change clearly.
| Term | Use in this lesson |
|---|---|
| normal test data | valid data the program should accept |
| boundary test data | data at the edge of valid limits |
| abnormal test data | invalid data the program should reject |
| trace table | table recording variable values during a dry run |
| dry run | manually stepping through an algorithm |
A Common Mix-Up
A common mistake is treating boundary data as always invalid.
Fix: Use the stated valid limits, and follow the algorithm line by line.
| Mistake | Correction |
|---|---|
| A common mistake is treating boundary data as always invalid. | Use the stated valid limits, and follow the algorithm line by line. |
Totalling, Counting, and Finding Values
The defining description of totalling is “adds each required value to a running Total.” Connect it with counting, whose role is “increments a Count when an event or condition is met.”
Required vocabulary and boundaries
| Idea | Precise role | Evidence or example |
|---|---|---|
| totalling | adds each required value to a running Total | Total ← Total + Mark |
| counting | increments a Count when an event or condition is met | Count ← Count + 1 |
| maximum | updates the stored largest value when a greater item is found | IF Value > Maximum THEN |
| minimum | updates the stored smallest value when a lower item is found | IF Value < Minimum THEN |
| average | divides the final total by the count of included values | Average ← Total / Count |
| safe initialisation | sets Total and Count to zero and initialises extrema from valid data | Maximum ← Values[1] |
Four-step exam routine
Identify the exact clue and name totalling only when its defining role fits.
State the mechanism or boundary: increments a Count when an event or condition is met.
Apply the idea to evidence such as “IF Value > Maximum THEN.”
Reject the tempting error that uses the greater-than comparison.
Reason Before Naming
These terms are usually assessed through short scenarios, so the mark often comes from matching the clue rather than recalling a definition alone.
Start by underlining the clue in the scenario, then decide what job that clue is describing. This keeps the answer tied to the concept being assessed.
totalling is the best match when the scenario clue is 'sum marks'.
| Scenario clue | What it proves |
|---|---|
| sum marks | totalling |
| number of passes | counting |
| highest score | maximum |
| lowest score | minimum |
When The Scenario Is Less Obvious
The question may include a boundary case or a tempting wrong answer. Use the exact role in the scenario as evidence.
- totalling: adding values to a running total
- counting: increasing a counter when an event occurs
- maximum: largest value found so far
- minimum: smallest value found so far
- average: total divided by count
A strong answer names the idea, quotes or paraphrases the clue, and explains the link in one sentence.
| Term | Use in this lesson |
|---|---|
| totalling | adding values to a running total |
| counting | increasing a counter when an event occurs |
| maximum | largest value found so far |
| minimum | smallest value found so far |
| average | total divided by count |
A Common Mix-Up
A common mistake is stopping at a broad Totalling, Counting, and Finding Values word instead of proving the answer from the clue.
Fix: Underline the clue first, then choose the term that explains that exact clue.
| Mistake | Correction |
|---|---|
| A common mistake is stopping at a broad Totalling, Counting, and Finding Values word instead of proving the answer from the clue. | Underline the clue first, then choose the term that explains that exact clue. |
Algorithm Errors and Corrections
The defining description of logic error is “the algorithm runs but produces an incorrect result.” Connect it with syntax error, whose role is “the written structure does not follow the required language or pseudocode form.”
Required vocabulary and boundaries
| Idea | Precise role | Evidence or example |
|---|---|---|
| logic error | the algorithm runs but produces an incorrect result | using < instead of <= at a boundary |
| syntax error | the written structure does not follow the required language or pseudocode form | missing ENDIF |
| trace table for error finding | reveals variable changes step by step during a dry run | Count never increases |
| boundary correction | repairs a comparison at the smallest/largest accepted or rejected value | change Age < 18 to Age <= 18 when 18 is accepted |
| loop correction | repairs the start, stop, or update so iteration terminates and covers the intended values | add Count ← Count + 1 |
| precision | writes the exact corrected pseudocode, program code, or flowchart logic | X > Y rather than 'X is larger' |
Four-step exam routine
Identify the exact clue and name logic error only when its defining role fits.
State the mechanism or boundary: the written structure does not follow the required language or pseudocode form.
Apply the idea to evidence such as “Count never increases.”
Reject the tempting error that changes an unrelated variable name.
Reason Before Naming
These terms are usually assessed through short scenarios, so the mark often comes from matching the clue rather than recalling a definition alone.
Start by underlining the clue in the scenario, then decide what job that clue is describing. This keeps the answer tied to the concept being assessed.
fix comparison is the best match when the scenario clue is 'boundary values fail'.
| Scenario clue | What it proves |
|---|---|
| boundary values fail | fix comparison |
| counter unchanged | add update |
| loop never stops | change condition/update |
| wrong branch runs | check IF condition |
When The Scenario Is Less Obvious
The question may include a boundary case or a tempting wrong answer. Use the exact role in the scenario as evidence.
- syntax error: mistake in the way code is written
- logic error: algorithm runs but gives the wrong result
- dry run: manual step-through of an algorithm
- correction: change that fixes the algorithm
A strong answer names the idea, quotes or paraphrases the clue, and explains the link in one sentence.
| Term | Use in this lesson |
|---|---|
| syntax error | mistake in the way code is written |
| logic error | algorithm runs but gives the wrong result |
| dry run | manual step-through of an algorithm |
| correction | change that fixes the algorithm |
A Common Mix-Up
A common mistake is stopping at a broad Algorithm Errors and Corrections word instead of proving the answer from the clue.
Fix: Underline the clue first, then choose the term that explains that exact clue.
| Mistake | Correction |
|---|---|
| A common mistake is stopping at a broad Algorithm Errors and Corrections word instead of proving the answer from the clue. | Underline the clue first, then choose the term that explains that exact clue. |
Turn knowledge into marks
A high-quality response does more than recall a term. It selects the command word, states the exact role, follows the mechanism in order, and connects the effect to the scenario.
Define precisely
For analysis stage, begin with the defining role: identifies the problem, requirements, abstraction, and decomposition needed. Do not replace the definition with an example.
Describe a process
Use an ordered chain. Name what enters, what changes or is checked, and what result follows. A useful anchor here is “writing the planned selection and loops.”
Apply or justify
Quote the scenario need, select loop correction, then link its role — repairs the start, stop, or update so iteration terminates and covers the intended values — to the required outcome.
Repair a misconception
Do not accept the claim that uses an informal description instead of the corrected condition. Replace it with the exact boundary: writes the exact corrected pseudocode, program code, or flowchart logic.
Mark-by-mark response ladder
- Name: use the exact syllabus term.
- Role: define what that term does or represents.
- Mechanism: describe the relevant steps in their logical order.
- Context: explain why that mechanism matters in the stated scenario.
- Boundary: avoid claiming more than the method guarantees.
Last-pass checklist
Mapped to Cambridge IGCSE Computer Science 0478 · 2026–2028 syllabus, version 5