AC9M7SP04 · Year 7 · Space

Algorithms to sort and classify shapes

ACARA v9 CONTENT DESCRIPTION design and create algorithms involving a sequence of steps and decisions that will sort and classify sets of shapes according to their attributes, and describe how the algorithms work

Once you can classify shapes by their properties, you can teach a clear procedure to do it automatically. An algorithm is a precise sequence of steps and decisions that completes a task, and writing one to sort and classify shapes is a perfect way to make your geometric reasoning explicit. This year you learn to design and create such algorithms, and to describe clearly how they work.

Turning a classification into an algorithm forces you to be exact. A vague sense of what makes a square will not do; you have to spell out the precise questions, in the right order, that distinguish every shape from every other. This is the same kind of thinking that underlies all of computing.

Decisions as a tree

A natural way to design a classification algorithm is as a decision tree. You start with a question about an attribute, such as does this shape have four sides. Each answer, yes or no, sends the shape down a different branch, where the next question waits. A shape without four sides might be classified by counting its sides; a shape with four sides leads to further questions about its angles and side lengths. Following the branches from top to bottom always arrives at a single, correct category.

A classification decision tree
A series of yes/no questions about attributes sorts a shape into its category.
Classifying a triangle: 4 sides? no. The lit path arrives at triangle.

The power of the tree is that each question narrows the possibilities, so only a few well-chosen questions can distinguish many shapes. The order of the questions matters: asking about the number of sides first makes sense, because the later questions about right angles only apply once you know you are dealing with a quadrilateral. Designing the questions and their order is the creative heart of building the algorithm.

Writing and describing the steps

The same logic can be written as an ordered list of steps, some of which are decisions. Step one might be to count the sides; step two, if there are not four, to classify by side count and stop; step three, if there are four, to check the angles and sides; step four, to name the quadrilateral accordingly. Written this precisely, the algorithm could be followed by another person or carried out by a computer, with no guesswork.

The algorithm as steps
The same logic can be written as a numbered sequence of steps and decisions.
Feeding in a triangle (3 sides): the run uses steps 1 to 2 then step 2 stops it, naming it triangle.

Being able to describe how the algorithm works is as important as creating it. A clear explanation lets someone else follow the steps, check that the logic is correct, and suggest improvements, perhaps a shorter path or a question in a better order. This blend of geometric knowledge and step-by-step logical design is exactly the kind of computational thinking the curriculum is building, and it connects the shapes you classify by eye to the precise procedures that power software, sorting and searching of every kind.

Teaching tip: play a guess-the-shape game where the student may only ask yes or no questions about attributes. The questions they choose, and the order they ask them in, are an algorithm in the making. Afterwards, write the questions down as a decision tree together to see the algorithm take shape.

Emphasise precision and order. Ask what happens if a step is missed or two steps are swapped, so the student sees that an algorithm only works when every step is clear and correctly sequenced. Describing each step in plain words is the habit that makes algorithmic thinking reliable.

Running the algorithm in order

An algorithm is only useful if it can be carried out exactly, and the clearest way to see that is to run it one step at a time. Taking a single shape and answering each question in turn shows how every answer decides which question comes next, until the procedure reaches a conclusion. Tracing it slowly like this is also how you check that the steps really do lead to the right category.

Trace the algorithm step by step
Running an algorithm means following its questions in order, one at a time, until it reaches a conclusion.
Step through the questions in order. So far 0 of 1 question answered; each answer decides what the algorithm asks next.

Sorting a whole batch

The same fixed procedure that classifies one shape can sort an entire collection. Fed a list of shapes, the algorithm sends each one through its questions and drops it into the bin for its category, until every shape has been placed. This is the real value of writing the rule as an algorithm: it works the same way on the first shape and the hundredth, with no extra thought required.

Sorting a batch into bins
Run on a list of shapes, the algorithm drops each one into the bin for its category.
Send the next shape through the classifier and watch it fall into its bin. An algorithm applied to a list sorts the entire list, one item at a time.

Improving the algorithm

Two algorithms can give the same answers yet do different amounts of work. The order in which the questions are asked decides how quickly each shape reaches its result, so asking the question that rules out the most cases first tends to be more efficient. Comparing orderings, and choosing a better one, is part of designing an algorithm well, not just making one that happens to work.

The order of questions matters
Two question orders classify the same shapes, but a better order asks fewer questions.
Asking about the number of sides first lets a triangle finish in a single question, so Order A needs 7 questions across the three shapes. A well-chosen first question ends many cases quickly.
Builds on: Classifying triangles, quadrilaterals and polygons (AC9M7SP02). That unit classified shapes by their properties; this unit builds step-by-step algorithms to sort and classify them automatically.
Quick self-check
1. What is an algorithm?
2. In a classification decision tree, each branch represents
3. An algorithm classifies a shape: it has 4 sides, all equal, all angles 90 degrees. The result is
4. Why must the steps of an algorithm be in a sensible order?
5. A good reason to describe how an algorithm works is so that
Teaching pack: free to printReady-to-teach plans, student sheets, cut-outs and answers for this unit. Print or save as PDF.