Wimzee Cambridge Academy
← All Revision Notes← IGCSE Computer Science

Algorithm Design and Problem-Solving

Revision Notes — IGCSE
CAIE IGCSE Computer Science (0478) • Topic 7 of 10 • Paper 1 & Paper 2
Mastered: 0 / 2

7.1 The Program Development Life Cycle

  1. Analysis — understand the problem: what the program must do, who will use it, what data goes in and comes out.
  2. Design — decompose the problem, design algorithms (pseudocode/flowcharts), design the data structures and the user interface.
  3. Coding — write the program in a high-level language.
  4. Testing — use test data to check the program works and fix errors.
  5. Maintenance — correct errors found later, adapt the program to new requirements, improve it.

Decomposition and abstraction

7.2 Algorithms

An algorithm is a sequence of steps that solves a problem. It must be precise, unambiguous and finite. Algorithms can be written as pseudocode, as a flowchart, or as structured English.

Flowchart symbols

SymbolMeaning
Rounded rectangle (terminator)Start or stop
ParallelogramInput or output
RectangleProcess / calculation / assignment
DiamondDecision (yes/no question)
ArrowDirection of flow
Circle / connectorJoins parts of the flowchart

Pseudocode conventions

INPUT name OUTPUT "Hello ", name IF mark >= 50 THEN OUTPUT "Pass" ELSE OUTPUT "Fail" ENDIF FOR i ← 1 TO 10 total ← total + i NEXT i WHILE count < 5 DO count ← count + 1 ENDWHILE REPEAT INPUT num UNTIL num > 0 CASE OF grade "A" : OUTPUT "Excellent" "B" : OUTPUT "Good" OTHERWISE : OUTPUT "Keep going" ENDCASE

7.3 Structure Diagrams and Trace Tables

A structure diagram shows the problem broken into sub-tasks in a hierarchy, from the main program down to individual procedures. A trace table records the value of every variable after each step so you can check an algorithm by hand and find logic errors.

Algorithm: total ← 0; FOR n ← 1 TO 4: total ← total + n*n | n | n*n | total | |---|---|---| | 1 | 1 | 1 | | 2 | 4 | 5 | | 3 | 9 | 14 | | 4 | 16 | 30 |

7.4 Validation and Verification

TypePurposeExamples
ValidationChecks data is sensible and within acceptable limits when it is enteredRange check, length check, type check, presence check, format check, check digit, lookup check
VerificationChecks data has been copied or transferred correctlyDouble entry, visual check, parity/checksum on transmission

7.5 Test Data

Test dataMeaningExample (age 11–18)
NormalShould be accepted15
AbnormalShould be rejectedabc, −5, 200
ExtremeAt the very edge of the acceptable range11 and 18
BoundaryJust outside the acceptable range10 and 19

7.6 Standard Methods of Solution

Linear search

Check each item in turn until the target is found or the list ends. Simple, works on unsorted data, but slow for large lists.

Binary search

Only works on a sorted list. Check the middle item: if it is the target, stop; if the target is larger, discard the lower half; if smaller, discard the upper half. Repeat. Much faster than a linear search on large lists.

Bubble sort

Compare each adjacent pair and swap them if they are in the wrong order, repeating passes until no swaps are needed. Easy to program but inefficient for large lists.

Bubble sort pass 1 on 5 2 9 1: 5 2 9 1 -> 2 5 9 1 -> 2 5 9 1 -> 2 5 1 9 Pass 2: 2 5 1 9 -> 2 1 5 9 Pass 3: 1 2 5 9 (sorted)

Exam trap

In a trace table, write the value of every variable at every step — including loop counters — and show the output column. Marks are given for the intermediate values, not just the final answer.

Five-minute drill

  1. State the five stages of the program development life cycle.
  2. Give three validation checks and an example of each.
  3. Explain why a binary search cannot be used on an unsorted list.
  4. Draw a trace table for: total ← 0; FOR i ← 1 TO 3; total ← total + 2*i; NEXT i.
  5. State two pieces of extreme test data for a program accepting marks 0–100.
Exam practice 1[6]

A program must accept 20 exam marks (0–100), reject invalid input, and output the highest mark. Write pseudocode for this program.

Mark scheme
  • Initialise highest ← 0 (1).
  • Loop 20 times with a FOR loop (1).
  • INPUT mark inside the loop (1).
  • Validation: WHILE mark < 0 OR mark > 100 DO INPUT mark ENDWHILE (1).
  • Comparison: IF mark > highest THEN highest ← mark ENDIF (1).
  • OUTPUT highest after the loop (1).
Exam practice 2[4]

Describe how a bubble sort would sort the list 4, 7, 2, 9 into ascending order. Show the list after each pass.

Mark scheme
  • Pass 1: compare 4 and 7 (no swap), 7 and 2 (swap), 7 and 9 (no swap) → 4, 2, 7, 9 (1).
  • Pass 2: 4 and 2 (swap), 2 and 7, 7 and 9 (no swap) → 2, 4, 7, 9 (1).
  • Pass 3: no swaps needed, so the list is sorted and the algorithm stops (1).
  • The largest item 'bubbles' to the end of the list on each pass (1).

Quick Reference

Life cycle: analysis -> design -> coding -> testing -> maintenance Decomposition = split into sub-problems; abstraction = remove detail Validation = sensible data; verification = copied correctly Test data: normal, abnormal, extreme (edges), boundary (just outside) Linear search = any order, slow; binary search = sorted only, fast Bubble sort = compare adjacent pairs, repeat until no swaps