BrightPath
Back to Course
Year 3 Coding & Computational Thinking

What is an Algorithm?

Learn how algorithms are step-by-step instructions that tell us exactly what to do, and why the order matters!

What is an Algorithm?

An algorithm is a set of step-by-step instructions that tell you exactly how to do something. You follow algorithms every day without even realising it!

Think about making a sandwich. You don't just throw everything together randomly -- you follow steps in the right order. That's an algorithm!

Real-Life Algorithm: Making a Vegemite Sandwich

1 Get two slices of bread
2 Pick up the butter knife
3 Spread butter on one slice
4 Spread Vegemite on top of the butter
5 Place the second slice on top
6 Cut the sandwich in half

Why Does Order Matter?

What if we mixed up the steps? Imagine this:

Step 1: Spread Vegemite on the bread

Step 2: Cut the sandwich in half

Step 3: Get two slices of bread -- Wait, we already spread on bread we don't have!

Steps that are in the wrong order create a bug -- the algorithm won't work properly!

Flowcharts: Drawing an Algorithm

A flowchart is a diagram that shows the steps of an algorithm using shapes and arrows. It makes algorithms easy to see and follow.

Flowchart: Getting Ready for School

START
Wake up
Brush teeth
Get dressed
Raining?
YES
Take umbrella
NO
No umbrella needed
Eat breakfast
Pack school bag
GO TO SCHOOL

Key shapes: Rounded boxes = Start/End | Rectangles = Steps/Actions | Diamonds = Decisions (Yes/No questions)

Debugging: Finding and Fixing Mistakes

When an algorithm has a mistake, we call it a bug. Finding and fixing bugs is called debugging. Even the best programmers have to debug their code!

Can you find the bug?

Here is an algorithm for brushing your teeth. One step is in the wrong place. Can you spot it?

1 Pick up your toothbrush
2 Brush your teeth for 2 minutes BUG!
3 Put toothpaste on the brush BUG!
4 Rinse your mouth with water
5 Put your toothbrush away

Writing Algorithms in Code

Computers follow algorithms written in code. Here is a simple algorithm that says hello and counts to 3:

// Algorithm: Say hello and count to 3

Step 1: Display "Hello! Let's count!"
Step 2: Display "1"
Step 3: Display "2"
Step 4: Display "3"
Step 5: Display "Done counting!"

In real JavaScript code, it looks like this:

// Algorithm: Say hello and count to 3
let message = "Hello! Let's count!";
message = message + "\n1";
message = message + "\n2";
message = message + "\n3";
message = message + "\nDone counting!";

Key Vocabulary

Algorithm

A set of step-by-step instructions to complete a task or solve a problem.

Sequence

The order in which steps happen. Getting the sequence right is very important!

Bug

A mistake or error in an algorithm or program that stops it from working correctly.

Debugging

Finding and fixing bugs in an algorithm or program. Like being a detective!

Flowchart

A diagram that uses shapes and arrows to show the steps in an algorithm.

Instruction

A single step or command that tells the computer (or person) what to do.

Worked Examples

1

Write an algorithm for making a cup of hot chocolate

Step 1: Boil the kettle.

Step 2: Put hot chocolate powder in a mug.

Step 3: Pour hot water into the mug.

Step 4: Stir with a spoon.

Step 5: Add marshmallows on top (optional!).

Answer: This is a 5-step algorithm. Each step must happen in order -- you can't stir before the water is in the mug!

2

Find the bug in this "crossing the road" algorithm

1. Walk to the crossing

2. Cross the road

3. Look left, look right, look left again

4. Wait for traffic to stop

Bug found: Steps 2, 3, and 4 are in the wrong order! You must look and wait before crossing. The correct order is:

1. Walk to the crossing → 2. Look left, right, left → 3. Wait for traffic to stop → 4. Cross the road

3

How many steps are in this algorithm?

Display "What is your name?"
Get the user's name
Display "Hello, " + name + "!"
Display "Welcome to our program!"

Step 1: Count each instruction. There are 4 lines.

Step 2: Check if each line is a separate instruction. Yes -- each line does one thing.

Answer: There are 4 steps in this algorithm. It asks for a name, gets the name, then displays two messages.

Knowledge Check

Select the correct answer for each question. Click "Check Answer" to see if you are right.

Question 1

What is an algorithm?

Question 2

What is a "bug" in programming?

Question 3

Here is an algorithm for planting a seed. Which step is in the wrong place?

1. Dig a hole in the soil

2. Water the soil

3. Put the seed in the hole

4. Cover the hole with soil

Question 4

In a flowchart, what shape is used for a decision (Yes/No question)?

Question 5

Why is sequence important in an algorithm?

Key Concepts Summary

Year 2: Sorting & Ordering Year 4: Loops Patterns