What is an Algorithm?

An algorithm is a step-by-step set of instructions that tells you exactly how to do something.

Reading is good — doing is better. Practice What is an algorithm? as an interactive lesson.

Try the lesson

Definition

An algorithm is a list of steps you follow in order to get something done. Every step is clear, and you do them one at a time. Computers use algorithms to know what to do, and so do people — like when you follow a recipe or tie your shoes.

Remember the rule

Every algorithm has a START, clear STEPS in ORDER, and an END result.

Key words

Algorithm
A step-by-step list of instructions to finish a task
Step
One single action you do as part of a bigger set of instructions
Order
Doing things in the right sequence, one after another
Input
What you start with or put in at the beginning
Output
What you get at the end after following all the steps
Sequence
The correct order that steps must happen in
Instruction
A direction that tells you exactly what to do
Loop
A step that repeats over and over until something is finished

Worked examples

How do you 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. Done! · If you skip step 2 and never open the jar, the whole algorithm breaks — order and completeness matter.

How does a computer sort these numbers from smallest to biggest: 5, 2, 8, 1?

1. Look at all the numbers. 2. Find the smallest one (1). 3. Put it first. 4. Find the next smallest (2). 5. Put it second. 6. Keep going until the list reads: 1, 2, 5, 8. · Computers do this same comparing process millions of times very fast.

How do you brush your teeth?

1. Pick up your toothbrush. 2. Put toothpaste on it. 3. Wet the brush. 4. Brush all teeth for 2 minutes. 5. Rinse your mouth. 6. Done! · This is an algorithm you already know and use every day.

How do you find the letter 'D' in the alphabet?

1. Start at the letter A. 2. Say the next letter. 3. Is it D? If no, go to step 2. If yes, stop — you found it! · The 'keep going until' part is called a loop.

How does a traffic light decide when to change?

1. Show green light for 30 seconds. 2. Show yellow light for 5 seconds. 3. Show red light for 30 seconds. 4. Go back to step 1 and repeat. · Even machines in the real world follow algorithms.

Common mistakes

  • Skipping steps — leaving out even one step can break the whole algorithm and give the wrong answer
  • Doing steps out of order — putting your shoes on before your socks does not work the same way
  • Being too vague — saying 'clean your room' is not an algorithm; you need specific steps like 'pick up toys, then make your bed'
  • Forgetting a stopping point — an algorithm must know when it is finished, or it goes on forever
  • Thinking algorithms are only for computers — people follow algorithms every single day for cooking, getting dressed, and more

FAQs

Does an algorithm have to be used by a computer?

No! People use algorithms too. A recipe, directions to a friend's house, and the steps to play a board game are all algorithms. Computers just follow them very very fast.

What happens if the steps are in the wrong order?

The algorithm breaks and you get the wrong result. Imagine putting on your coat before your shirt — it does not work right. Order is very important.

How is an algorithm different from a rule?

A rule tells you what is allowed or not allowed. An algorithm tells you exactly how to do something, step by step. A rule says 'no running inside.' An algorithm says 'step 1, step 2, step 3 — done.'

Can an algorithm have only two steps?

Yes! An algorithm just needs to be complete and in order. If two steps are enough to finish the job correctly, that is a perfectly good algorithm.

Why do computers need algorithms?

Computers cannot think on their own. They need exact instructions for everything they do. A programmer writes the algorithm, and the computer follows it perfectly every single time.

What is the difference between an algorithm and a program?

An algorithm is the plan or list of steps. A program is when someone writes that plan in a special language the computer can read. The algorithm comes first, then the program turns it into computer code.

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 (2nd Grade Technology)