Algorithm reasoning means deciding whether a set of steps really does the job, using evidence and not a feeling. This section teaches four habits for that: tracing, comparing, choosing test data and telling two kinds of checking apart.
It sits inside problem solving and algorithms, and it assumes you can already read basic pseudocode.
What does this section cover?
Each lesson takes one skill and applies it to a small, original algorithm.
- Writing a trace table that exposes an off-by-one error shows how one extra loop pass becomes visible.
- Choosing normal, boundary and invalid test data builds a test plan from a written specification.
- Comparing two algorithms against one contract asks which version is correct, not which looks shorter.
- Separating validation from verification clears up two words that students swap.
How do the four skills connect?
Tracing is the base. A trace table tells you what the algorithm actually does, and that is the only fair starting point for testing or comparing it.
Test data comes next, because a trace is only as good as the input you feed it. Comparing two algorithms then means tracing both on the same inputs, and validation versus verification tells you what each check can and cannot prove.
A small example to orient you
This algorithm should count how many of four marks are 50 or above.
SET count = 0
FOR i = 1 TO 4
INPUT mark
IF mark > 50 THEN
SET count = count + 1
END IF
NEXT i
OUTPUT count
Try the marks 62, 50, 49 and 80. The algorithm outputs 2, but the correct answer is 3, because 50 counts as a pass.
A normal input such as 62 would never reveal the fault. The boundary value 50 does, and the trace shows the comparison 50 > 50 is false. The repair is to write >=, which is one character and a whole mark.
Who should start where?
Pick the lesson that matches the mistake you keep making.
| If this happens to you | Start with |
|---|---|
| Your final value is wrong and you cannot see why | Trace table lesson |
| You are told to “test your algorithm” and freeze | Test data lesson |
| Two answers look right and you cannot choose | Comparing two algorithms |
| You mix up validation and verification | Validation versus verification |
The restricted pseudocode trace trainer lets you practise tracing on your own device, and the mistake log and paper-error review helps you record which kind of slip you repeat.
When you are ready to test the whole set, use the section practice questions. If you would like a teacher to go through your own pseudocode, see online one-to-one Computer Science tuition.