Algorithms need a goal

Computer Science · Key Stage 1 · The School

Steps are not enough on their own

An algorithm needs two things. Steps to follow. And a GOAL, so you know when you are finished. Without a goal, nobody can tell if the algorithm worked. "Do some steps" is not a real task at all. The goal comes first.

What does "sorted" mean?

The task is "sort the socks." That sounds clear, but it is not. Sorted by colour? By size? Into pairs? Each goal needs different steps. Say the goal first: "put every sock into a pair with its match." Now the steps can be written properly.

Checking you reached the goal

When the steps finish, check the goal. Did every sock get a pair? If some are still loose, the algorithm did not actually finish, even if you ran out of steps. Checking against the goal is what tells you the difference between finished and merely stopped.

Tidying a bookshelf, with and without a goal

Task one: "tidy the bookshelf." No goal is given, so everyone tidies differently — one person just squares up the spines, another sorts by colour. Task two: "put every book in order by author's surname, A to Z." Now everyone knows exactly what finished looks like. Same shelf, same books, but only the second task has a real goal attached to it, so only the second one can actually be checked.

Writing the goal first

Before writing any steps, write the goal in one sentence. What should be true when you are done? Only then write the steps that get you there. Skipping this makes the steps easy to write and impossible to check. Always start with the goal.

The School — all subjects · Knowledge map