Tracing maximum and minimum algorithms
In a trace table, Largest only changes on rows where this test is true. If Number is equal or smaller, the Largest cell stays the same as the row above. Smallest uses < instead.
Understanding Tracing maximum and minimum algorithms in IGCSE Computer Science Paper 2
What it does: The middle column shows the result of the test. The row with FALSE keeps Largest at 9, while the TRUE row stores the new value. 4 is less than 8, so the test is true and Smallest is updated to 4 on this row. 20 > 12 is true, so this is a row where the Largest cell changes. A tie never makes the comparison true, so Smallest does not change. The value is the same as the row above. When tracing Largest and Smallest together, each column must be checked separately. Largest stays 5, but Smallest becomes 2.
Common mistakes: Largest should only change when the new Number is bigger, so the test must use >. With < the trace table would store smaller values and Largest would go down instead of up. Every IF in Cambridge pseudocode needs THEN at the end of the condition line. It should be IF Number < Smallest THEN.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 286–295) and word search (Modules 275–295).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
IF Number > Largest THENFill in the Blanks
Spot the Error
Student with a class code? Join your class →