AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

Plan then program

Week 14 · Unit 6: Be a designer · 3 lessons
1

Order changes the result

Computing 2: Unit 6, pp. 80–91
GoalShow that the order of steps in an algorithm can change the result.
New words
algorithm · a set of steps, in order, that tells how to do a taskorder · which step comes first, which comes next and which comes lastwall · a blocked square that a character cannot go through
Explanation

An algorithm is a set of steps in a good order. If the order is wrong, the character may not get where it should go. Look at the map. The cross is a wall. “Down 2, then right 3” walks into the wall. “Right 3, then down 2” reaches the flower. The same steps in a different order can give a different result.

Worked examples
Algorithm B: right 3, then down 2. The cat walks along the top and then down. It reaches the flower.
Algorithm A: down 2, then right 3. After down 1 the cat is next to the wall. Down 2 sends it into the wall, so it cannot get to the flower.
Good orderBad order
1 write the card1 put the card in the envelope
2 put it in the envelope2 post it
3 write the address3 write the card
4 post it4 write the address
Order matters for everyday tasks too. Here are the steps for sending a birthday card, first in a good order and then in a bad order.
Class activity

Floor map: make a map on the floor with 5 columns and 4 rows of squares, using chalk, tape or paper. Put a toy flower in one square and a book in another square for a wall. A child is the character. Another child reads out an algorithm, such as “right 2, down 3”. The character moves one square for each number. Does the character reach the flower? Try a different order of the same steps. Find two different algorithms that both reach the flower.

Practice
1
Which algorithm reaches the star: A: right 3, down 2, or B: down 2, right 3?
2
Put the steps for wrapping a present in a good order. A: add the ribbon. B: put the gift in the box. C: wrap the box in paper. D: close the box.
3
Write the algorithm for the route of the cat.
4
In the first map, the algorithm “right 1, down 2, right 2” starts at the cat. Does it reach the flower?