← ACARA Digital Technologies Years 7–8

Re-tracing a corrected algorithm

After a fix, trace the algorithm again with the same failing input, then other inputs, to check the output now matches what was expected.

Understanding Re-tracing a corrected algorithm in ACARA Digital Technologies Years 7–8

What it does: A new trace table is made for the corrected algorithm, using the same input that failed before, and each row is recorded again. A new trace table shows what the fixed steps really do. The old table records the buggy steps, so it can't be trusted. One input may only test one path through an IF or loop. Try other inputs so every path is checked. A fix can break something else. Re-tracing old inputs that used to work helps catch a new error. When the traced output doesn't match the expected output, there is still a bug. Look at the trace table for the row where it goes wrong.

Common mistakes: After a fix, a new trace table with the same input shows total is 6, so the output should be 6. OUTPUT total + 2 prints 8, so the output does not match what was expected. It should be OUTPUT total. The variable is read in as marks but the IF tests mark. When you re-trace with the same input, mark has no value. The first line should be INPUT mark.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

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 420–481) and word search (Modules 420–519).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
You fixed a bug that gave the wrong output for the input 5. What should you do first to check the fix?
Trace it using a brand new input and forget about 5Trace the corrected algorithm again using the input 5
Matches
Fix made: changed > to >=. Only re-traced the other inputs, not the failing one.
↓
The original failing input was not traced again, so you cannot be sure the fix solved that error. Re-trace the same failing input first.
Applying
Meanings
Term
re-trace
Meaning
After a fix, trace the algorithm again with the same failing input, then other inputs, to check the output now matches what was expected.
Practice
total ← 0
Testing
Gaps
IF mark 50 THEN OUTPUT "Pass"
Check Answer
Spots
3 SET total ← total + 2
4OUTPUT total + 2

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Ermine' badge — Tundra Streak, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. You fixed a bug that gave the wrong output for the input 5. What should you do first to check the fix?
A. Trace it using a brand new input and forget about 5
B. Trace the corrected algorithm again using the input 5 ✓
Re-trace with the same failing input first. If the output now matches what was expected, the fix worked for that case.
2. Which is the better way to re-trace a corrected algorithm?
A. Draw a new trace table and fill it in from the start ✓
B. Reuse the old trace table and only change the last row
A new trace table shows what the fixed steps really do. The old table records the buggy steps, so it can't be trusted.
3. Your re-trace with the failing input now gives the expected output. Are you finished testing?
A. No, test other inputs that take the other paths too ✓
B. Yes, one passing trace proves the whole algorithm works
One input may only test one path through an IF or loop. Try other inputs so every path is checked.
4. An algorithm has IF mark >= 50 THEN OUTPUT "Pass" ELSE OUTPUT "Fail". You fixed the operator and traced mark = 60. What should you also trace?
A. A mark below 50, such as 30, to test the ELSE path ✓
B. Another mark above 50, such as 70, to test the THEN path again
Testing a mark below 50 tests the other path. Another high mark only repeats the same path.
5. After your fix, an input that used to work now gives the wrong output. What does this tell you?
A. The fix is fine because the original bug is gone
B. The fix created a new error that needs to be found ✓
A fix can break something else. Re-tracing old inputs that used to work helps catch a new error.

Match the Pairs

Input 45, expected 'Pass', actual now 'Pass' → Re-tracing with the same input that failed shows the fix worked: the actual output now matches the expected output.
New trace table: score 50, 49, 100 → Trace the corrected algorithm with other inputs too, so every path is tested and the fix did not create a new error.
Start a fresh trace table for the same failing input after the fix, and fill it in again from the first step → score | passed | OUTPUT 45 | Yes | Pass
Test the other paths too: use one input for the IF branch and one for the ELSE branch → Test 1: score 80 -> expect Pass Test 2: score 20 -> expect Fail
Fix made: changed > to >=. Only re-traced the other inputs, not the failing one. → The original failing input was not traced again, so you cannot be sure the fix solved that error. Re-trace the same failing input first.
Fix made. Traced score 50 only. Output is correct, so the algorithm is finished. → Only one input and one path was checked. Test the other paths too, to make sure the fix did not create a new error.

Key Term

re-trace
After a fix, trace the algorithm again with the same failing input, then other inputs, to check the output now matches what was expected.

Fill in the Blanks

1. IF mark >= 50 THEN OUTPUT "Pass" ELSE OUTPUT "Fail"
Hint: Type the relational operator that lets a mark of exactly 50 pass, so the re-trace with the failing input now works.
2. INPUT n REPEAT n TIMES OUTPUT "Hi"
Hint: Type the variable name that holds how many times the loop must run, so a re-trace with the same input gives the right count.
3. IF age >= 13 AND age <= 18 THEN OUTPUT "Teen" ENDIF
Hint: Type the logical operator that needs both conditions true, then re-trace with ages inside and outside the range.
4. IF score > 50 THEN OUTPUT "Pass" ELSE OUTPUT "Fail"
Hint: Type the keyword for the other path, so you can test that path too after the fix.
5. average ← total / count OUTPUT average
Hint: Type the arithmetic operator that divides, then re-trace to check the fix did not create a new error.

Spot the Error

Question 1
A SET total ← 0
B REPEAT 3 TIMES
C SET total ← total + 2
D OUTPUT total + 2
Line D — After a fix, a new trace table with the same input shows total is 6, so the output should be 6. OUTPUT total + 2 prints 8, so the output does not match what was expected. It should be OUTPUT total.
Question 2
A INPUT marks
B IF mark >= 50 THEN
C OUTPUT "Pass"
D ELSE
E OUTPUT "Fail"
Line A — The variable is read in as marks but the IF tests mark. When you re-trace with the same input, mark has no value. The first line should be INPUT mark.
Question 3
A SET count ← 0
B WHILE count > 3
C SET count ← count + 1
D OUTPUT count
Line B — Re-tracing the corrected algorithm shows count starts at 0, so count > 3 is false straight away and the loop never runs. The condition should be count < 3 so it outputs 1, 2, 3.
Question 4
A INPUT age
B IF age >= 13 OR age <= 18 THEN
C OUTPUT "Teen"
D ELSE
E OUTPUT "Not a teen"
Line B — With OR the condition is true for every age. Testing the other paths with age 10 gives "Teen" instead of "Not a teen". It should be AND so both conditions must be true.
Question 5
A INPUT a
B INPUT b
C SET total ← a + b
D SET average ← total / 3
E OUTPUT average
Line D — A fix can create a new error, so re-trace it. Two numbers were added, so the average must divide by 2. Dividing by 3 gives the wrong output, for example a=4 and b=6 gives 3.33 instead of 5.

Student with a class code? Join your class →