← ACARA Digital Technologies Years 5–6

Predicting the outcome of an algorithm

To trace an algorithm, pick starting values, follow each step in order, write down how the values change, and say what it shows at the end.

Understanding Predicting the outcome of an algorithm in ACARA Digital Technologies Years 5–6

What it does: Making a written prediction before running lets you check your tracing and spot mistakes. Using more than one input shows how branches and loops behave with different values. To predict an outcome, pick starting values first. Then follow each step in order to find the answer. Tracing means following every step in order. Writing the changes down helps you avoid mistakes. total starts at 2. After adding 5 it is 7. After adding 1 it is 8. So it shows 8. A tracking table has a row for each step. It shows what every variable holds as you go. 8 is not 10 or more, so the condition is false. The ELSE path runs and shows Free.

Common mistakes: = asks if two things are equal, so the total would never change when you trace it. To store a new value, use the assignment arrow: SET total ← total + 2. The loop does not say what to repeat, so you cannot trace how many times lives goes down. It should be REPEAT 3 TIMES.

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 106–119) and word search (Modules 106–132).

Take this worksheet further — free with Cloodit

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

Learning
Duo
Before you follow an algorithm, what do you need to choose first?
Starting values, like score = 3The final answer it will show
Matches
count = 0 REPEAT 3 TIMES count = count + 2 Output: count Prediction: 3 (guessed without tracing)
↓
The prediction was guessed instead of traced. Following each repeat gives 2, 4, 6, so the output is 6.
Applying
Meanings
Term
trace
Meaning
To trace an algorithm, pick starting values, follow each step in order, write down how the values change, and say what it shows at the end.
Practice
SET total TO 0
Testing
Gaps
SHOW total # it shows
Check Answer
Spots
2SET total ← start
3SET total = 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. Before you follow an algorithm, what do you need to choose first?
A. The final answer it will show
B. Starting values, like score = 3 ✓
To predict an outcome, pick starting values first. Then follow each step in order to find the answer.
2. Which is a good way to predict what an algorithm will show?
A. Guess from the first step only
B. Follow each step in order and write down how the values change ✓
Tracing means following every step in order. Writing the changes down helps you avoid mistakes.
3. Algorithm: SET total to 2. ADD 5 to total. ADD 1 to total. SHOW total. What does it show?
A. 8 ✓
B. 5
total starts at 2. After adding 5 it is 7. After adding 1 it is 8. So it shows 8.
4. What is a tracking table used for?
A. Recording how each variable changes after every step ✓
B. Making the algorithm run faster
A tracking table has a row for each step. It shows what every variable holds as you go.
5. Algorithm: IF age >= 10 THEN SHOW "Ticket" ELSE SHOW "Free". If age is 8, what does it show?
A. Free ✓
B. Ticket
8 is not 10 or more, so the condition is false. The ELSE path runs and shows Free.

Match the Pairs

trace table → A table where you write down the value of each variable after every step, so you can see how the values change
start with score = 3 → Choose a starting value to test, then follow each step from there to see what the algorithm shows at the end
Predict first, then check: work out the answer on paper, then run the algorithm to see if you were right → I predict: total will be 10. Now run it and compare.
Try different inputs: test the same algorithm with another starting value because the outcome might change → Test 1: age = 8 Test 2: age = 14
count = 0 REPEAT 3 TIMES count = count + 2 Output: count Prediction: 3 (guessed without tracing) → The prediction was guessed instead of traced. Following each repeat gives 2, 4, 6, so the output is 6.
Trace table: only wrote the final value of score, skipped the steps in between → The table must show how the value changes after every step, not just the final value.

Key Term

trace
To trace an algorithm, pick starting values, follow each step in order, write down how the values change, and say what it shows at the end.

Fill in the Blanks

1. SET total TO 4 ADD 3 TO total SHOW total # it shows 7
Hint: Follow the steps in order and type the number total ends up as.
2. SET count TO 0 REPEAT 3 TIMES: ADD 2 TO count SHOW count # it shows 6
Hint: Add 2 once for each repeat, then type the final value of count.
3. SET temp TO 20 IF temp > 25 THEN SHOW "Hot" ELSE SHOW "Cool" # 20 > 25 is false
Hint: Check the condition with the starting value. Is it true or false?
4. SET n TO 10 REPEAT UNTIL n < 5: SUBTRACT 3 FROM n SHOW n # 10, 7, 4 so it shows 4
Hint: Keep going until the loop stops. Type the last value n has.
5. SET a TO 3 SET b TO a * 2 SHOW b # table: a = 3, b = 6
Hint: Look at the tracking table. Type the variable that holds the value shown.

Spot the Error

Question 1
A INPUT start
B SET total ← start
C SET total = total + 2
D OUTPUT total
Line C — = asks if two things are equal, so the total would never change when you trace it. To store a new value, use the assignment arrow: SET total ← total + 2.
Question 2
A SET lives ← 3
B REPEAT 3
C SET lives ← lives - 1
D OUTPUT lives
Line B — The loop does not say what to repeat, so you cannot trace how many times lives goes down. It should be REPEAT 3 TIMES.
Question 3
A INPUT age
B SET ticket ← 5
C IF age < 10
D SET ticket ← 2
E END IF
F OUTPUT ticket
Line C — The IF line is missing THEN, so you cannot follow which step runs when the condition is true. It should be IF age < 10 THEN.
Question 4
A SET n ← 4
B SET n * 2 ← n
C SET n ← n + 1
D OUTPUT n
Line B — The arrow must point at the variable being changed, with the new value on the right. It should be SET n ← n * 2, so tracing gives 8 and then 9.
Question 5
A SET x ← 10
B REPEAT UNTIL x ← 4
C SET x ← x - 3
D OUTPUT x
Line B — A REPEAT UNTIL needs a condition that is true or false, not an assignment. It should be REPEAT UNTIL x <= 4. Tracing then gives x = 10, 7, 4 and an output of 4.

Student with a class code? Join your class →