Head office, Rana Pratap Bagh, Delhi011 2721 1512+91 97116 99511

Algorithms: instructions step by step

An algorithm is a list of clear steps in the right order. Learn to write, test and fix algorithms on paper.

Let us begin

The big idea

Every time you brush your teeth or make a glass of lemon water, you follow steps in an order. A list of steps that solves a job is called an algorithm. Computers need algorithms for everything they do.

An algorithm is a set of clear steps that must be followed in the right order to finish a job. A recipe is an algorithm. So is the way you get ready for school.

Order matters. If you put on your shoes before your socks, the job goes wrong. Each step must also be clear. A computer cannot guess what you mean, so we must say exactly what to do.

Sometimes an algorithm has a mistake. A mistake in the steps is called a bug. Finding and fixing it is called debugging. Test your steps by following them one by one, just like a computer would.

We can also write algorithms for a robot on a grid. We might say forward 2 or turn right. We use these small, exact commands to guide the robot to a square.

Lemon water as an algorithmFour boxes in a row joined by arrows pointing right: pour the water, squeeze a lemon, add sugar, and stir and drink.An algorithm: steps in the right order 1. Pour the water 2. Squeeze a lemon 3. Add sugar 4. Stir and drink Change the order and the drink goes wrong!
Steps in a good order make an algorithm.

Worked examples

See how it works

  1. Lemon water algorithm

    Step 1: Pour water in a glass. Step 2: Squeeze a lemon into it. Step 3: Add some sugar. Step 4: Stir and drink. If we stir before we add the sugar, the sugar will not mix well, so order matters.

  2. A robot on a grid

    The robot stands on square (1,1) facing up. The first number is the column and the second is the row. Forward 2 moves it to (1,3). Turn right makes it face right. Forward 3 moves it to (4,3). So it stops at (4,3).

  3. Finding the biggest number

    Numbers: 7, 3, 9, 4. Say the biggest is 7. Look at 3. It is not bigger, so keep 7. Look at 9. It is bigger, so the biggest is now 9. Look at 4. It is not bigger. The biggest number is 9.

Try it at home

Be the human robot

You will need

  • a cushion or a bag
  • a friend or family member
  • paper and pencil

What to do

  1. Put the cushion on the floor a few steps away from your friend.
  2. Write on paper a few commands: forward 1 step, turn left, turn right.
  3. Your friend closes their eyes and stands as the robot. You read the commands one at a time.
  4. Does the robot reach the cushion? If not, find the bug in your steps.
  5. Fix the steps and try again. Then swap places.

Ask a grown-up: An adult should check that the floor is clear so nobody trips or bumps into furniture.

Fun fact

The word algorithm comes from the name of a scholar from long ago, Al-Khwarizmi, who wrote about step-by-step methods for sums.

Practice sheet

Check what you learned

Write your answers in a notebook, or print this sheet and write on it. When you finish, mark your work with the answer key.

Practice sheet: Algorithms: instructions step by step (Classes 3-5, Computers and coding)

  1. What is an algorithm?
  2. Put in the right order: (a) wear shoes (b) wear socks (c) tie the laces.
  3. Why does the order of steps matter?
  4. A robot stands on (1,1) facing up. Each forward step moves it one square up. Where is it after forward 3?
  5. A robot stands on (1,1) facing up. It does forward 2, turn right, forward 1. Where does it stop? (Column first, then row.)
  6. Write an algorithm of four steps for drinking water from a bottle.
  7. This algorithm has a bug: 1. Eat the sandwich. 2. Spread butter on bread. 3. Take two slices of bread. What is wrong?
  8. Use the biggest-number method on 12, 5, 18, 9. Which is the biggest?
  9. Write simple steps to find the smaller of two numbers.
  10. A robot starts on (1,1) facing up. It does: forward 2, turn right, forward 3, turn right, forward 1. Where does it stop and which way does it face?

Answer key

Answers: Algorithms: instructions step by step

Do the practice sheet first, then check here. If an answer is different from yours, read the lesson again and try once more.

  1. A list of clear steps, in the right order, that solves a job.
  2. (b) wear socks, (a) wear shoes, (c) tie the laces.
  3. If the steps are in the wrong order the job goes wrong or cannot be done.
  4. (1,4).
  5. Forward 2 gives (1,3). Turn right makes it face right. Forward 1 gives (2,3). It stops at (2,3).
  6. Sample: 1. Pick up the bottle. 2. Open the cap. 3. Drink some water. 4. Close the cap.
  7. The steps are in the wrong order. The correct order is: take two slices of bread, spread butter, then eat the sandwich.
  8. 18.
  9. Sample: 1. Look at both numbers. 2. If the first is smaller, it is the answer. 3. If not, the second is the answer.
  10. Forward 2 gives (1,3). Turn right: facing right. Forward 3 gives (4,3). Turn right: facing down. Forward 1 gives (4,2). It stops at (4,2), facing down.
WhatsApp us