What is an Algorithm?

What is an algorithm?

It’s a reasonably straightforward question isn’t it? But one that yields quite a few debates. I’ve written the following answer to ‘what is an algorithm?’ question based around the STEM computing classes with children.

First it helps I find it helps if you pretend you’re asking one of these to solve a problem; if you don’t tell them everything they get into a real mess!

Robot algorithm


An Algorithm is a precise set of instructions to solve a  problem*

For me, that gets to the heart of the definition: solving a problem in a precise manner.

The problem being solved could be as simple as calculating the number of times ‘as’ appears in this sentence or as complicated as finding the quickest route for a journey across rush hour London.

What’s interesting about algorithms and not obvious from their definition is that once created, executed and observed they can often be refactored/reused to solve other problems that require the same generic process to solve.

For example, I’ve lost count of the times I’ve written a function to solve a specific problem then subsequently refined and abstracted it slightly to solve a much broader range of problems, often implemented using polymorphism. This elasticity, once you recognise it, is for me, the root of writing maintainable code. e.g. In the example above, rather than searching for a specific word, you would refine the algorithm to search for any word. This is obviously beyond the stated curriculum but a nice example of a way to illustrate a seemingly abstract part of the curriculum.

I’ve been asked about efficacy a few times as part of the definition and my view is that its not part of the definition. Efficacy is important for Computing Science but it’s not part of the definition.

* As some children are pretty young, under 7,  we don’t talk about Turing machines. But I know a few people favour this addition to the definition and describe it as something that could be simulated by a Turing complete machine. Although I do wonder if we could somehow simplify and adapt this into the design and discussion of Turing machines…

Computational Thinking

Computational Thinking. It’s the current buzz phrase of the moment with regard education news. It’s the ‘thing’ we must teach our children.

So what is Computational Thinking?

Although it sounds like it, we don’t want you to think like a computer. It’s really set of ways to think that help you solve problems in a systematic and logical way. More importantly, they are methods that can be ‘abstracted’ and applied to more than one problem.

For example, knowing how to use flour, water and yeast to make dough means you can make breads, pizzas, pasta, cakes.

Computational Thinking will also help you to describe a solution that can be easily translated into a computer program. i.e. Programming

But the real value here extends beyond just programming as they are ways to think about solving problems. Ways that will serve you well solving real-world problems such as: finding the fastest route somewhere, finding a different route if there’s an unforeseen problem, ordering large groups of information, building things, etc

Common types of Computational Thinking are:

Problem Decomposition:

This is the art of taking a hammer to big overwhelming problem and smashing it up into small bite size pieces. Our brains get very tired thinking about solving a big problem in one go.

Think of a child eating solid food. We wouldn’t just give them a whole chicken and a giant potato. We’d help them by cutting it up into ‘bite sized pieces.’

That’s what Problem Decomposition helps us to do, mentally. For example, asking someone to build the Great Wall of China is a Herculean task, and one you’d rightly decline, but at its most fundamental it’s just putting one stone on top of the other. And doing it over and over again. The repetition of an algorithm is an important concept too. We call it a loop.

Problem Decomposition allows you turn an insurmountable problem into something manageable.

Google famously asks questions of its software engineering candidates such as:

How many golf balls can fit into a School Bus?

This is designed to test your problem decomposition skills along with some basic maths. What they are really checking is that you can see beyond the irrelevant parts of the description to the real problem. That you can break it down to a simple volume problem. A rectangular solid’s volume minus the volume of the spheres calculation. A good computational thinker would ignore the colourful but meaningless description of the bus and visualise something like a fish tank filled with ping pong balls.

Pattern Recognition

Being able to see patterns in collections of data such as strings of letters, numbers, objects, graphs is pretty much a fundamental part of Computational Thinking. The good news here is that our brains are pretty much Pattern recognition machines! The Rorschach test is this principle in action.

Pattern Recognition is really powerful as it lets us see beyond the noise of data to the repeating structure behind it. In our previous example of the bus filled with golf balls, pattern recognition lets us zoom through past the windows, wheels and doors and see a familiar maths problem.

Pattern Recognition allows you to see sequences like 1,2,3,5,8,13,21 and see beyond the string of numbers to a simple function that can generate it. It’s a great skill to acquire and leads onto the next part of Computational Thinking, Abstraction.


Abstraction allows you to develop a solution for a single problem and make it generic so it can be used to solve other problems.

i.e. It gives you mindset to look for what’s ‘variable‘, the parts that can be taken out and replaced with an ‘x’

For example, we use time in the short-term in minutes and hours, but we’ve abstracted this into decades and centuries when we’re describing events far in the past or future.

Abstraction is being able to take that seemingly random string of numbers we just saw and, if not immediately see it’s a Fibonacci sequence, know that there is a functional abstraction, i.e. a formula, an algorithm, that can describe the sequence: F_n = F_{n-1} + F_{n-2},\!\,


As we’ve just seen, we can decompose a problem into a pattern or series of patterns that can be abstracted and then turned into an algorithm.

An algorithm is a precise set of instructions to achieve some desired outcome

It could be you want to count the number of words in an article, or find the most common colour in Monet’s Lilies or work out how high a Wimbledon tennis ball bounces when dropped of a 10 foot wall. You’ll probably notice that these problems are really maths problems and you can solve them without a computer but it’s MUCH quicker to use a computer. For example, an average computer can count to a billion in about 4 seconds, how long would it take you?

This is why computational thinking is important, it allows us to solve problems that are either too large for our brains to solve manually or to solve them in a fraction of the time.  Humans are tool users and the computer is our best tool yet.

Whatever the ‘thing’ is you are trying to do, being able to solve your problem by articulating as a set of instructions, such as a computer program, is a very powerful way of thinking and one that lets you know quickly whether you actually understand the problem properly.

Computational Thinking is centered around these four concepts and while programming is the most common form of expressing a solution, it’s reach extends far beyond the computer.