1.Why should I care?
Computers are fast and obedient but have no common sense. Before an engineer writes a line of code, they split the job into pieces and write each piece as steps so precise that a machine cannot misread them. This habit, called computational thinking, is how every controller, from a greenhouse to a Mars rover, gets designed.
- ◇ Decompose an engineering job into smaller jobs that can each be solved and checked.
- ◇ Write an algorithm as ordered, numbered steps with quantities, units and a stopping rule.
- ◇ Spot a step that is too vague for a computer to follow and rewrite it precisely.
2.Predict
Which instruction could a watering controller actually follow?
Guess first. Being wrong here is how the surprise works.
3.Discover
Choose 'Seedling watering'. Use Up and Down to put the six steps in order, then mark the two steps a computer could not follow exactly. Check, then compare each vague step with its precise version.
Loading the interactive…
Can't use the interactive? Read a description instead
The step orderer lists six shuffled steps for automatic watering: read moisture at 07:00; if moisture is 35 % or more skip to the last step; open the valve; keep it open until 45 % or 60 s; close the valve; log the time and moisture. Two steps start vague ('Check the plants in the morning', 'Water until the soil is wet enough'); the task is to order the steps and spot those two.
4.Checkpoint: guided practice
Check what you just discovered before going on. Hints appear after a wrong answer.
Practice 1
Which step is too vague for a computer?
5.Watch
→ Notice how each step of the counting method is exact enough for anyone to repeat, and how a cleverer algorithm does the same job in far fewer steps.
Counting a room full of people two at a time shows how a clever, exact procedure beats a slow one.
Length: see YouTube · captions on YouTube · source
Nothing loads from YouTube until you press play.
The video is optional: everything you need is also in the lesson text and the interactive.
6.Understand
Decomposition: one big job, several small ones
'Look after the seedlings' is too big to solve in one go. Split it: sense (read moisture), decide (is it too dry?), act (open and close a valve), record (write a log line). Each piece is small enough to design, test and fix on its own, and different people can work on different pieces.
An algorithm is a precise recipe
An algorithm is a finite list of steps that solves one of those small jobs. Every step must be unambiguous: two people, or a computer, would do exactly the same thing. That usually means naming a quantity and a unit (35 % moisture, 60 s), and saying what happens next.
Every algorithm needs inputs, outputs and an end
Ask three questions of any algorithm. What does it read (inputs)? What does it produce (outputs)? How does it stop? A watering step without a stopping rule floods the tray. Good stopping rules often have a backup, such as 'or 60 s have passed', in case a sensor fails.
Explain it another way
Writing an algorithm is like writing directions for a friend who takes everything literally. 'Turn left at the shop' fails if there are two shops. 'Turn left at the second junction, by the red post box' works.
An algorithm is a finite sequence of well-defined instructions that maps inputs to outputs and terminates. Decomposition splits a problem into sub-problems with clear interfaces: what each piece receives and what it hands on.
Industrial irrigation controllers are written exactly this way: a schedule, a sensor threshold, a maximum valve-open time and a log. The maximum time is there because moisture sensors do fail, and a stuck-open valve can waste water or drown plants.
Worked example 1
Decompose 'keep the vaccine fridge between 2 °C and 8 °C' and write the decide step precisely.
Pieces: read the temperature every minute; decide; switch the compressor; log and alarm. Decide step: If the temperature is above 6 °C, switch the compressor on. If it is below 3 °C, switch it off. If it is outside 2–8 °C for 5 minutes in a row, sound the alarm. Each line names a number, a unit and an action.
Common mix-ups
- An algorithm has to be written in a programming language.
✓ An algorithm is the method. It can be numbered steps, a flowchart or code; code is just one way to write it down. - If a person understands the steps, a computer will too.
✓ People fill gaps with common sense. Computers need every quantity, unit and stopping rule spelled out.
7.Practice on your own
Practice, not a test. Wrong answers get a hint and another try.
Practice 2
Why do engineers decompose a big job before coding it?
Practice 3
A step says 'Open the valve until moisture reaches 45 %'. What is the safest improvement?
Practice 4
For the watering algorithm, which is an output?
Practice 5
Why must 'Close the water valve' come after 'Keep the valve open until …'?
8.Apply it
Choose a simple machine at home or school (a kettle, an automatic door, a hand dryer). Decompose its job into sense, decide, act and record. Write the decide step as numbered, precise steps with at least one number and unit, and one backup limit.
9.Reflect
Concepts: Decomposition, algorithms and flowcharts