7.1 The Program Development Life Cycle
- Analysis — understand the problem: what the program must do, who will use it, what data goes in and comes out.
- Design — decompose the problem, design algorithms (pseudocode/flowcharts), design the data structures and the user interface.
- Coding — write the program in a high-level language.
- Testing — use test data to check the program works and fix errors.
- Maintenance — correct errors found later, adapt the program to new requirements, improve it.
Decomposition and abstraction
- Decomposition — breaking a large problem into smaller sub-problems that are easier to solve and can be written as separate subprograms.
- Abstraction — removing unnecessary detail so only the information needed to solve the problem is kept.
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
| Symbol | Meaning |
|---|---|
| Rounded rectangle (terminator) | Start or stop |
| Parallelogram | Input or output |
| Rectangle | Process / calculation / assignment |
| Diamond | Decision (yes/no question) |
| Arrow | Direction of flow |
| Circle / connector | Joins parts of the flowchart |
Pseudocode conventions
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.
7.4 Validation and Verification
| Type | Purpose | Examples |
|---|---|---|
| Validation | Checks data is sensible and within acceptable limits when it is entered | Range check, length check, type check, presence check, format check, check digit, lookup check |
| Verification | Checks data has been copied or transferred correctly | Double entry, visual check, parity/checksum on transmission |
7.5 Test Data
| Test data | Meaning | Example (age 11–18) |
|---|---|---|
| Normal | Should be accepted | 15 |
| Abnormal | Should be rejected | abc, −5, 200 |
| Extreme | At the very edge of the acceptable range | 11 and 18 |
| Boundary | Just outside the acceptable range | 10 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.
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
- State the five stages of the program development life cycle.
- Give three validation checks and an example of each.
- Explain why a binary search cannot be used on an unsorted list.
- Draw a trace table for: total ← 0; FOR i ← 1 TO 3; total ← total + 2*i; NEXT i.
- State two pieces of extreme test data for a program accepting marks 0–100.
A program must accept 20 exam marks (0–100), reject invalid input, and output the highest mark. Write pseudocode for this program.
- 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).
Describe how a bubble sort would sort the list 4, 7, 2, 9 into ascending order. Show the list after each pass.
- 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).