An algorithm is a clear set of steps and decisions. A classification algorithm asks yes/no questions about a shape's sides and angles, in an order that gives each shape its own name, and you test it on one shape of every class.
A sorting machine at a factory has to name every shape that rolls past, with no one to help. What questions would you build into it, and in what order?
An algorithm is a precise set of steps, including decisions, that always gives the right result. A classification algorithm sorts shapes into classes by asking yes/no questions about their attributes (sides, angles, parallel sides). It can be drawn as a flowchart or a decision tree, or written as numbered steps (pseudocode).
Two things make one work: every shape reaches exactly one answer, and the questions are in the right order.
Predict: Read the problem and decide what you think before you try anything. A wrong guess is fine: it shows you what to look for.
Try: Try it on the board and compare the result with your prediction.
Investigate: Work out why it happens, one step at a time.
Modify: Change the problem on purpose and see what happens.
Practise: A few on your own, to check you have it.
Make: Make your own problem using what you have learned. Expect a few tries; that is normal.
Make your prediction first. Help opens once you've locked it in.
PredictRead the problem and decide what you think before you try anything. A wrong guess is fine: it shows you what to look for.
An algorithm with one question
Would you be happy with that answer from a sorting machine?
TryTry it on the board and compare the result with your prediction.
Follow the algorithm
Read each shape's description, answer the question, and press the button to go on.
Try it yourselfYour edits are saved in this browser.
Follow this two-question algorithm for each triangle in turn. How does it name the 4, 4, 4 triangle? Compare with your prediction.
Use the board. This ticks when you get there.
InvestigateWork out why it happens, one step at a time.
What goes wrong
Which class does the algorithm confuse with another?
Read Pia's working. What name did the rectangle get?
Pia tests her algorithm on a rectangle. Click the line where she wrongly decides it works.
ModifyChange the problem on purpose and see what happens.
Design and test
Measure first. Which question is the most specific?
Try it yourselfYour edits are saved in this browser.
Put the steps of a triangle algorithm in order.
Pieces (click to add)
Your program
Run the fixed algorithm on all three triangles. Does every one get the right name?
Use the board. This ticks when you get there.
Run the quadrilateral algorithm on all five shapes.
Use the board. This ticks when you get there.
PractiseA few on your own, to check you have it.
Tracing algorithms
Try it yourselfYour edits are saved in this browser.
In the fixed triangle algorithm, how many questions does a scalene triangle need before it is named?
The quadrilateral algorithm asks at most how many questions before naming any of its five shapes?
Review: a triangle has angles 90°, 45° and 45°. How many of its sides are equal?
MakeMake your own problem using what you have learned. Expect a few tries; that is normal.
Design a classifier
Now write an algorithm that sorts triangles by their angles into acute, right-angled and obtuse. Test it on one triangle of each class, and say how it works to a partner.
Try it yourselfYour edits are saved in this browser.
Need a hint?
Answer each question using the shape's description.
Another hint
If the key names the wrong shape, find the question you answered wrongly.
Run the quadrilateral algorithm on all five shapes again, and say each answer aloud as you go.
Use the board. This ticks when you get there.
For teachers
Students follow, fix and test algorithms that classify triangles and quadrilaterals, and describe how each works (AC9M7SP04, nodes 1 and 2). About 40 minutes.
I can follow an algorithm and say what each decision does.
I can put the questions of a classifier in an order that works.
I can test an algorithm on one shape of every class.
Before class
Do the Run board yourself first. Students need the triangle and quadrilateral classes (Classifying shapes lessons).
The one idea: each shape must reach its own name, so the most specific question comes first. A short algorithm can be wrong; testing on one shape of every class finds it (Pia's mistake).
The board follows the key one question at a time; it is the same tool students use for living things in science. Students design on paper: the Make task asks for an algorithm for triangles by angles, drawn as a flowchart or written as numbered steps.
Judging two algorithms for efficiency (fewest questions) and for edge cases (the kite) are wider ideas.
This links to Code: an algorithm written in steps is a program with if and else.
Running the lesson
Predict: ask what the machine should say for the equilateral triangle.
Run: ask which triangle the algorithm gets wrong, and why.
Investigate: ask what test shapes Pia should have used.
Modify: ask students to describe the quad algorithm in words.
Make: ask a partner to run the algorithm on a shape the author hasn't tried.
The hard part (on purpose)
Ordering the questions. Ask students to say which shape each question separates before they put it in a position.
When students get stuck
A student asks the general question first. Ask: What would a square be called by this question? Fix: Ask the most specific question first.
A student tests on one shape. Ask: Which classes has your test not reached? Fix: Test one shape of every class.
A student has a path with no end. Ask: Where does a 'no' lead? Fix: Every yes and every no must lead on to another question or a name.
Stretch and support
Stretch: Compare two correct algorithms for the same job: which asks fewer questions on average? Then write the triangle algorithm in Python with `if` and `else`.
Support: Give students the questions on cards and ask them to lay out the order before they use the board.
Where it leads
This completes AC9M7SP04.
Where it leads: algorithms in code (the Code pathways), flowcharts for other decisions, and decision trees in Probability.
What each step is for
an algorithm with one question: Committing to what a one-question triangle algorithm says about an equilateral triangle shows whether they check the order and the cases.
follow the algorithm: Following a two-question algorithm on three test triangles shows the order that gives the equilateral triangle its own name.
what goes wrong: Order and missing cases are the problems; the general question first gives a less specific name (Pia); testing needs one of each class.
design and test: Ordering the decisions of a triangle algorithm, running the quadrilateral one, and finding the shape it cannot handle shows design, tracing and limits.
tracing algorithms: Counting questions and tracing the path for a shape, mixed; the number of questions a key needs is the planted idea; the triangle review keeps classes fresh.
design a classifier: Writing their own algorithm in steps shows whether they put the specific questions first and cover every class.
Now you can
Follow an algorithm and say what each decision does.
Put the questions of a classifier in an order that works.