What you'll learn
This revision guide covers algorithm design and analysis as specified in the WJEC GCSE Computer Science curriculum. You'll learn how to represent algorithms using flowcharts and pseudocode, trace algorithm execution, and analyse algorithm efficiency. These skills are fundamental to computational thinking and will appear across both examination papers.
Key terms and definitions
Algorithm — a sequence of precise, unambiguous instructions that can be followed to solve a problem or complete a task
Pseudocode — a structured, English-like notation for describing algorithms without using a specific programming language syntax
Flowchart — a graphical representation of an algorithm using standardised symbols connected by arrows to show the flow of control
Trace table — a table used to manually track the values of variables as an algorithm executes, step by step
Decomposition — breaking down a complex problem into smaller, more manageable sub-problems
Abstraction — removing unnecessary detail from a problem to focus on the essential features
Pattern recognition — identifying similarities or common features within or between problems
Algorithm efficiency — how well an algorithm performs in terms of time taken (time complexity) or memory used (space complexity)
Core concepts
Computational thinking
Computational thinking is the process of approaching problems in a logical, systematic way that allows them to be solved by computers. It consists of four key elements:
Decomposition involves breaking complex problems into smaller parts. For example, creating a school timetabling system can be decomposed into:
- Allocating teachers to subjects
- Assigning rooms to classes
- Scheduling break times
- Avoiding timetable clashes
Abstraction means identifying what's important and filtering out unnecessary details. When designing a student record system, you might abstract the essential information (name, date of birth, class group) while ignoring less relevant details (favourite colour, preferred lunch).
Pattern recognition identifies repeating features. In a stock control system, you might notice that checking item availability follows the same pattern whether checking books, uniforms, or equipment.
Algorithm design creates step-by-step solutions once the problem has been decomposed, abstracted and patterns identified. The algorithm must be clear, unambiguous and executable.
Representing algorithms with flowcharts
Flowcharts use standardised symbols to visualise algorithm logic. You must know these symbols for the WJEC exam:
Oval/Terminator — marks the start or end of an algorithm
Parallelogram/Input-Output — represents data being input or output
Rectangle/Process — shows a process or calculation being performed
Diamond/Decision — indicates a decision (usually a Boolean condition) with two or more possible paths
Arrow/Flow line — shows the direction of flow through the algorithm
Flowcharts are particularly useful for:
- Planning algorithm structure before coding
- Communicating logic to non-programmers
- Identifying potential errors in logic
- Understanding unfamiliar code
Key flowchart rules:
- Flow generally moves from top to bottom
- Each decision symbol must have at least two exits (typically "Yes/True" and "No/False")
- Every path must eventually reach a terminator
- Use clear, specific labels in each symbol
Writing pseudocode
Pseudocode follows structured programming conventions without requiring exact syntax. The WJEC specification uses specific pseudocode conventions you must learn:
Assignment:
variable ← value
score ← 0
Output:
OUTPUT "Enter your name"
OUTPUT score
Input:
INPUT username
Selection (IF statements):
IF condition THEN
statements
ENDIF
IF age >= 18 THEN
OUTPUT "Adult"
ELSE
OUTPUT "Child"
ENDIF
Iteration (loops):
WHILE condition DO
statements
ENDWHILE
FOR counter ← start TO end
statements
ENDFOR
Arrays:
names[5]
names[1] ← "Sarah"
Arrays in WJEC pseudocode typically use 1-based indexing (first element is position 1, not 0).
Key pseudocode principles:
- Use clear, descriptive variable names
- Indent statements inside selection and iteration structures
- Use capital letters for keywords (IF, THEN, WHILE, OUTPUT)
- Be consistent with notation throughout
Trace tables
A trace table tracks variable values as an algorithm executes. Each row represents one step, and each column represents a variable or output.
Trace tables are essential for:
- Checking algorithm logic without running code
- Identifying logic errors
- Understanding unfamiliar algorithms
- Demonstrating algorithm execution in exams
Creating a trace table:
- Draw a table with one column for each variable, plus columns for input and output if needed
- Add a row for each meaningful step in the algorithm
- Update only the variables that change at each step
- Leave cells blank if variables haven't been initialised yet
- Record values after operations complete, not during
Trace tables are particularly important when working with loops — you must show the variable values for each iteration.
Algorithm correctness and testing
An algorithm is correct if it produces the expected output for all valid inputs. Testing verifies correctness using different test data types:
Normal (typical) data — realistic values the algorithm should handle routinely (e.g., testing age validation with "25")
Boundary (extreme) data — values at the limits of acceptable ranges (e.g., testing age validation with "0" and "120")
Erroneous (invalid) data — values that should be rejected (e.g., testing age validation with "-5" or "ABC")
Algorithms should handle all three data types appropriately through validation (checking input meets requirements) and error handling.
Algorithm efficiency
Algorithm efficiency measures how well an algorithm performs. At GCSE level, you need to understand:
Time efficiency — how execution time increases as input size grows. A more efficient algorithm completes faster, especially with large datasets.
Space efficiency — how much memory an algorithm requires. More efficient algorithms use less storage.
Consider searching for a name in a list:
Linear search checks each item sequentially until finding a match (or reaching the end). If the list has 1000 names and the target is last, it requires 1000 comparisons. Time increases proportionally with list size.
Binary search (on sorted data) repeatedly divides the search space in half. Finding an item in 1000 sorted names requires only about 10 comparisons. Much more efficient for large datasets, but requires data to be sorted first.
You should be able to:
- Identify which of two simple algorithms is more efficient
- Explain why one algorithm is more suitable than another for a given situation
- Recognise that some problems have no efficient solution
Worked examples
Example 1: Flowchart to pseudocode conversion
Question: The flowchart below shows an algorithm that inputs numbers until a total exceeds 100. Convert this algorithm to pseudocode. (6 marks)
[Flowchart shows: Start → total ← 0 → INPUT number → total ← total + number → Decision "total > 100?" → No (loops back to INPUT) → Yes → OUTPUT total → End]
Mark scheme answer:
total ← 0
WHILE total <= 100 DO
INPUT number
total ← total + number
ENDWHILE
OUTPUT total
Marks awarded for:
- Correct initialisation (1 mark)
- Correct WHILE loop structure with condition (2 marks)
- Correct INPUT statement (1 mark)
- Correct calculation (1 mark)
- Correct OUTPUT statement (1 mark)
Example 2: Trace table completion
Question: Complete the trace table for this algorithm. (4 marks)
count ← 1
total ← 0
WHILE count <= 4 DO
total ← total + count
count ← count + 1
ENDWHILE
OUTPUT total
| count | total | output |
|---|---|---|
| 1 | 0 | |
Mark scheme answer:
| count | total | output |
|---|---|---|
| 1 | 0 | |
| 2 | 1 | |
| 3 | 3 | |
| 4 | 6 | |
| 5 | 10 | 10 |
Marks awarded for:
- Correct count values (1 mark)
- Correct total values (2 marks)
- Correct output value (1 mark)
Example 3: Algorithm efficiency comparison
Question: A programmer needs to find the highest test score from 500 students. Compare the efficiency of these two approaches:
Algorithm A: Check each score sequentially, keeping track of the highest found so far.
Algorithm B: Sort all 500 scores into descending order, then select the first score.
Which algorithm is more efficient? Justify your answer. (3 marks)
Mark scheme answer:
Algorithm A is more efficient (1 mark).
Algorithm A requires checking each score once (500 comparisons) (1 mark).
Algorithm B must first sort all scores (which requires many more comparisons/operations than 500) then select the first score, making it slower overall (1 mark).
Alternative acceptable answer: Algorithm A uses less processing time / Algorithm B performs unnecessary operations since only one value is needed.
Common mistakes and how to avoid them
Confusing flowchart symbols — practise drawing flowcharts regularly. Remember: diamonds are always decisions (not processes), parallelograms are input/output (not rectangles). Create flashcards with each symbol and its purpose.
Incorrect trace table updates — only change variables when the algorithm explicitly modifies them. Don't skip rows for each loop iteration. Show your working step by step, even if values don't change.
Inconsistent pseudocode notation — stick to WJEC conventions throughout. Don't mix programming language syntax (like Python's "=" for assignment) with pseudocode notation ("←"). Check the specification for correct keywords.
Missing algorithm steps — ensure your algorithm handles all cases, including edge cases. Always include initialisation steps and proper loop termination conditions. Test mentally with extreme values.
Incomplete efficiency analysis — don't just state which algorithm is faster; explain why with reference to the number or type of operations required. Consider both time and space efficiency.
Forgetting array indexing — WJEC pseudocode typically uses 1-based indexing (first element at position 1). If you're used to programming languages that use 0-based indexing, be extra careful in exams.
Exam technique for "Algorithms: Design and Analysis"
Command word "State" requires a brief answer without explanation (usually 1 mark). For "Explain" or "Justify", you must give reasons (typically 2+ marks). "Complete" means fill in missing parts of pseudocode, trace tables or flowcharts exactly as required.
Trace table questions award marks for accuracy across multiple steps. One error can lose multiple marks if it affects subsequent rows. Work carefully and check your arithmetic. Show at least 3-4 iterations for loops unless told otherwise.
Algorithm writing questions reward clear structure and correct notation. Use proper indentation to show structure. Include all necessary keywords (IF...THEN...ENDIF, WHILE...DO...ENDWHILE). Test your algorithm mentally with sample data before finalising your answer.
Marks typically awarded at 1 mark per correct element — for pseudocode, each statement/structure usually earns 1 mark. For explanations, each distinct point scores separately. Plan to write as many valid points as there are marks available.
Quick revision summary
Algorithms are precise step-by-step solutions to problems. Represent them using flowcharts (with standardised symbols for processes, decisions, input/output) or pseudocode (using WJEC notation). Use trace tables to track variable values during execution. Apply computational thinking: decomposition breaks problems down, abstraction removes unnecessary detail, pattern recognition identifies similarities. Test algorithms with normal, boundary and erroneous data. Evaluate efficiency by comparing time and space requirements. Master flowchart symbols, pseudocode keywords, and trace table methodology for exam success.