0% found this document useful (0 votes)
53 views4 pages

Algorithms and Sequence

An algorithm is a step-by-step guide that helps computers perform tasks, similar to a recipe for baking a cake. Algorithms are present in everyday activities and must be arranged in the correct sequence for successful execution. Understanding algorithms is essential for programming, as they dictate how instructions are followed to achieve desired outcomes.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views4 pages

Algorithms and Sequence

An algorithm is a step-by-step guide that helps computers perform tasks, similar to a recipe for baking a cake. Algorithms are present in everyday activities and must be arranged in the correct sequence for successful execution. Understanding algorithms is essential for programming, as they dictate how instructions are followed to achieve desired outcomes.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

algorithms

How computer programs know what to do

An algorithm is just like a recipe. If you want to bake a


cake, there are steps you need to follow.
An Algorithm is a list of all the
steps that need to be performed Even if you have never baked before, if you follow those
steps, you will be able to make a cake. Algorithms help
in order to complete a task. computers know exactly what to do.
Every computer program is an algorithm that has been
programmed using code for computers to understand.

Algorithms in everyday life


Even though you don't realize it, almost everything we do everyday follows an algorithm. You follow
an algorithm every morning when you prepare for school.

ALGORITHM FOR GETTING


READY FOR SCHOOL
1. Wake up
2. Take your bath
3. Get dressed
4. Eat your breakfast
5. Pack your bags
6. Go to school

If you program this algorithm into a


robot, the robot will also be able to go
to school everyday.

How to create an algorithm


You need to start by thinking about all the steps
involved in the task you wish to perform, then
arrange the steps in the right sequence, starting ALGORITHM FOR MAKING
from the first to the last. A CUP OF TEA
Each step needs to be clear so that anybody
reading the algorithm knows exactly what to do. 1. Boil water
2. Pour water in a cup
Once you are done listing the steps, you have 3. Put a bag of tea
created an algorithm for that task.
4. Add sugar
Every computer program, from your mobile phone 5. Stir together
music player, the ATM machine and even websites
you visit follow an algorithm.

13 David Ogunshola
www.earlycodingbook.com
sequence
Making things follow the right order

All instructions given to a computer contain a list of steps, but these steps need to
be performed in a particular order for the task to be correctly done.

A sequence is the order the steps Even when the instructions are correct, there would
be a bug if the sequence is wrong. For computers to
needed to complete a task must complete tasks, we need to write our codes or
follow. algorithms in the right sequence.

Example: list all the numbers from 1 to 5 in the right sequence


Even though all the numbers from 1 to 5 are listed in both boxes, only one of them follows the correct order.

1 3 4 2 5 1 2 3 4 5

Make a cup of tea


Look at the steps that need to be performed to make a cup
of tea. Can you arrange these steps in the right sequence?

List of steps (not arranged) What is the right sequence?


Add sugar

Stir the contents

Add teabag

Pour the water in a cup

Add Milk

Boil water

17 David Ogunshola
www.earlycodingbook.com
pathway ninjas
Following Algorithms You will need crayons

To become a good programmer, you need to understand how computers follow instructions,
In Pathway Ninjas, you pretend to be a robot. You have been given an algorithm to follow.
Each algorithm has instructions and a pathway map to follow. Follow each step in the algorithm and do exactly what it says
on the map.

Pathway 1
Follow each step on the map
1. Go right one step
2. Go up two steps and colour the box orange
3. Go up two steps
4. Go right one step and colour the box blue
5. Go right two steps and colour the box green
6. Go down four steps and colour the box
purple
7. Go left 2 steps and colour the box yellow

Map
(Start where the arrow is)

If you do not have crayons, just use your pen to color the box.
You should have something like this.

Pathway 2
Follow each step on the map

1. Go right five steps and colour the box


2. Go left one step
3. Go up two steps and colour the box
4. Go left two steps and colour the box
5. Go up two steps
6. Go right three steps and colour the box
7. Go down three steps and colour the box

Map
(Start where the arrow is)

22 David Ogunshola
www.earlycodingbook.com
Pathway Ninjas without words
Now let us convert our words to codes. These would be our codes

Go up Go Right Go Left Go Down Colour Colour


Red
Can you solve the following algorithms?

Pathway 6
1.

2. Go Right
3.

4.

5.

Map
(Start where the arrow is)

Pathway 7
1.

2. Go Right
3.

4.

5.

Map
(Start where the arrow is)

24 David Ogunshola
www.earlycodingbook.com

You might also like