Step-by-Step: How Algorithms Work
Byte the cheerful robot stands at a kitchen counter holding numbered cards, carefully lining up each step to make a jam sandwich in exactly the right order
- Define an algorithm as an ordered list of steps that solves a task.
- Arrange a set of mixed-up steps into the correct working order.
- Explain why changing the order of steps can make a task fail.
- Identify which step in a list is too vague for a robot to follow.
Key terms
- Algorithm
- A clear ordered list of steps.
- Order
- Which step comes first, next, and last.
- Precise
- Exact and clear, with no guessing.
- Step
- One small action in the list.
What an Algorithm Is
An algorithm is just a fancy word for a clear list of steps that does a job in the right order. You already use algorithms every day. Getting dressed is one, because you put on socks first and then shoes. A computer follows an algorithm the same careful way, one step after another.
Why Order Matters
Order matters a lot in an algorithm. If you try to put your shoes on before your socks, it just does not work. The steps are the same, but the wrong order breaks the whole task. So you must ask what should happen first, then next, then last, like links in a chain.
Steps Must Be Precise
Good steps need to be precise, which means exact and clear. A fuzzy step like do the food thing is too vague for a robot to follow. A precise step like pour one cup of water into the bowl tells the robot exactly what to do and how much, so there is no guessing left at all.
Worked examples
Put these getting-ready steps in order.
- Socks must go on before shoes can fit.
- So put on socks first, then put on shoes.
Answer: Socks first, then shoes is the correct order.
Which step is precise enough for a robot?
- Do the water thing is too fuzzy to follow.
- Pour one cup of water into the bowl is exact.
Answer: Pour one cup of water into the bowl is precise.
Activity
Drag these jam-sandwich steps into the correct order so Byte can follow them
Practice
Write the ordered steps for making a jam sandwich.
Rewrite do the food thing as one precise clear step.
Common mistakes to avoid
- Order never changes the resultWrong order can break a task even when every step is correct.
- Fuzzy steps are fine for robotsRobots need precise steps because they cannot guess what you mean.
Check your understanding
What is an algorithm?
Byte wants to put on socks and shoes. Which order works?
Which step is the MOST precise and easy for a robot to follow?
Why does the order of steps matter in an algorithm?
Recap
An algorithm is a clear ordered list of steps that does a job. Order matters because the wrong order can break the task. Steps must also be precise, telling a robot exactly what to do so there is no guessing at any point.
Reflect
What everyday task of yours is really an algorithm?