Algorithms & Sequences

An algorithm is a set of step-by-step instructions that must be followed in the right order to get a job done.

Reading is good — doing is better. Practice Algorithms & sequences as an interactive lesson.

Try the lesson

Definition

An algorithm is a list of clear, ordered steps that tell someone (or a computer) exactly what to do to solve a problem or complete a task. A sequence is the order those steps go in. If the steps are out of order, the algorithm will not work correctly, just like a recipe that says 'eat the cake' before 'bake the cake' would not make sense.

Remember the rule

Every algorithm needs: a clear START, steps in the RIGHT ORDER, and a clear END — skip any one and it breaks!

Key words

Algorithm
A set of step-by-step instructions used to complete a task or solve a problem.
Sequence
The order in which steps happen — first, second, third, and so on.
Step
One single action or instruction inside an algorithm.
Input
The information or ingredients you start with before following the steps.
Output
The result you get after all the steps are finished.
Loop
A part of an algorithm that repeats the same step or steps more than once.
Condition
A yes-or-no question inside an algorithm that decides which step comes next.
Debug
Finding and fixing a mistake in an algorithm so it works correctly.

Worked examples

Write an algorithm to make a peanut butter sandwich.

1. Get two slices of bread. 2. Open the peanut butter jar. 3. Use a knife to spread peanut butter on one slice. 4. Press the second slice on top. 5. Put the knife in the sink. Done! · If you did step 4 before step 3, you would press two plain pieces of bread together and get no peanut butter at all.

Write an algorithm to brush your teeth.

1. Pick up your toothbrush. 2. Put toothpaste on the brush. 3. Wet the brush with water. 4. Brush all your teeth for two minutes. 5. Rinse your mouth with water. 6. Put the toothbrush away. · The sequence matters — putting toothpaste on AFTER you wet the brush is fine, but brushing BEFORE putting on toothpaste would not clean your teeth well.

A robot needs to walk from a desk to the door. The room is 5 steps wide. Write the algorithm.

1. Start at the desk. 2. Take 1 step forward. 3. Take 1 step forward. 4. Take 1 step forward. 5. Take 1 step forward. 6. Take 1 step forward. 7. Stop at the door. · Computers need every tiny step spelled out — they cannot guess or skip ahead like people can.

Find the mistake (debug) in this algorithm for watering a plant: 1. Pour water on plant. 2. Fill the watering can with water. 3. Walk to the plant.

The steps are out of order. The correct sequence is: 1. Fill the watering can with water. 2. Walk to the plant. 3. Pour water on the plant. · This is called debugging — fixing the sequence so the algorithm actually works.

Write an algorithm using a loop to jump 4 times.

1. Start standing up. 2. Repeat 4 times: Jump up and land back down. 3. Stop jumping. · Instead of writing 'jump' four separate times, a loop lets us say 'repeat 4 times' to keep the algorithm short and neat.

Common mistakes

  • Putting the steps in the wrong order — the sequence is just as important as the steps themselves.
  • Leaving out a step because it seems obvious — computers and robots do only exactly what they are told, nothing more.
  • Forgetting a clear ending — an algorithm without a stopping point can go on forever.
  • Writing steps that are too vague, like 'make it nice,' instead of specific actions a computer could actually follow.
  • Thinking algorithms are only for computers — algorithms are used every day for things like tying shoes, cooking, and getting ready for school.

FAQs

Is a recipe the same thing as an algorithm?

Yes! A recipe is a great real-life example of an algorithm. It lists the ingredients (inputs), gives you steps in order (the sequence), and tells you when you are done (the output).

What happens if one step is missing from an algorithm?

The algorithm might give the wrong answer or not work at all. For example, if a sandwich recipe forgot to say 'put the two slices together,' you would end up with two open pieces instead of a sandwich.

Do computers follow algorithms?

Yes, every program on a computer, tablet, or phone is built from algorithms. When you play a game or search for something, the computer is following millions of tiny steps very, very fast.

How is a sequence different from just a list?

A list can be in any order, but a sequence has a specific order that matters. The steps 'put on shoes' then 'tie laces' only make sense in that order — flip them and it does not work.

Can an algorithm have more than one right answer?

Sometimes yes! There can be different algorithms that all solve the same problem. One sandwich algorithm might have 5 steps and another might have 7, but both can end up making a correct sandwich.

What does it mean to debug an algorithm?

Debugging means finding the mistake and fixing it. If your algorithm has steps in the wrong order, or a step is missing, you look it over carefully, find the problem, fix it, and try again.

Want the whole picture for your child?

Every K–6 subject, an AI tutor that teaches step by step, unlimited practice, and a reward world.

Start a 3-day free trial

Related concepts (3rd Grade Technology)