The Computing Primary National Curriculum. Loathe it or loathe it, it specifies quite clearly that children need to be able to “create and debug simple programs” even at Key Stage 1. It goes on to talk about understanding what algorithms are and predicting the behaviour of simple programs.

For teachers who do not have a computing background – and even many who do – this can seem quite daunting. What is a computer program or an algorithm? What is debugging and how do you do it? How can a Year 1 child predict the behaviour of a computer program when they can’t even predict what day of the week it will be tomorrow?

So let’s spend just 5 minutes learning the basics.

What is an algorithm?

An algorithm is basically a step-by-step procedure to solve a problem. You use them in KS1 maths all the time:
“If I take a number of pencils and I add one more to them, I will have the number of pencils plus 1”.

It is very clearly defined so that everyone who puts a particular number in at the start will get the right result at the other end:
“If I start with 3 pencils, I will end up with 4 pencils.”
“If I start with 16 pencils, I will end up with 17 pencils.”

An algorithm is a way to solve a problem. As such, it could easily be written in English or in another language. It doesn’t have to be written for a computer. For example, the algorithm:
“When you line up for assembly, stand behind the person who is before you in the register,” should give you the same result every time.

What is debugging?

Take that last example: “When you line up for assembly, stand behind the person who is before you in the register.” The writer of this algorithm might think it is fool proof, but an experienced teacher has probably recognised some of the problems that this algorithm presents. By trying out the algorithm and seeing what happens, you can see where problems occur and fix them with tweaks or additions to your initial algorithm. This is debugging.

Debugging process

Problem 1: The first child in the register doesn’t know where to stand, leaving an uncontrolled snaking conga of children around the classroom

Algorithm improvement 1: “When you line up for assembly, stand behind the person who is before you in the register. If you are the first person in the register, stand by the door.”

Problem 2: The algorithm doesn’t make exceptions for children who are absent.

Algorithm improvement 2: “When you line up for assembly, stand behind the person who is before you in the register. If you are the first person in the register, stand by the door. If you can’t find the person before you in the register, stand behind the person who is next before you in the register.”

Sometimes when you debug, you run into unexpected problems. Testing an algorithm many times helps to identify and address these problems with specific solutions.

Problem 3: Sometimes a child will rush quickly to the line and stand immediately behind a person who is two places before them in the register. When the child who should be between them arrives, the two children who are already there inexplicably decide that this child has lost the right to that position in the line.

Algorithm improvement 3: “When you line up for assembly, stand behind the person who is before you in the register. If you are the first person in the register, stand by the door. If you can’t find the person before you in the register, stand behind the person who is next before you in the register. If the person who should be in front of you arrives later than you do, you must let them into the line in front of you.”

As well as fixing errors that are spotted during testing, debugging also means that children will need to use logic to predict what will happen next. This is not as difficult as you might think. It can be as simple as “If I give this robot, who is standing 5 steps from the edge of a cliff, the instruction to walk 10 steps forward, can you predict what the problem will be?” Predicting what will happen is the same as in any other subject, such as reading – it’s a way of them demonstrating that they really understand.

So what is a program and how is it different from an algorithm?

If you remember, an algorithm is way of solving a specific problem that could be explained in any language, such as English or a computer programming language. A program is simply a list of instructions that a computer has been given in a language that it understands.

An algorithm works on solving a specific problem. But a program doesn’t have to do that. It is just a list of instructions that the computer must follow, in order, in its own language. This might include a few different algorithms that solve different problems and those problems might or might not be related.

While you can write algorithms that can be carried out by people or computers, a program will only be carried out by a computer.

The simplest way I can explain the difference is that an algorithm is a step-by-step way to solve a specific problem while a program is just a list of instructions to do. You can see that there is some overlap between the two, but they are conceptually quite different.

Think of it like a maths test. A child might be given a reasoning paper with 15 questions on it. Each question might require the child to solve different problems. For example, question 1 might be on negative numbers, question 2 might be on missing lengths and question 3 might be on fractions. The test is the program – it contains a list of instructions that the child needs to follow. The child will try to use a different algorithm to solve each question. The child needs to use a specific algorithm that you have taught it in order to answer the question. But question 1 might have nothing to do with question 2, so they’ll probably need an entirely different algorithm for that.

And so it is with a program. It is a list of instructions that the computer must follow. There might be different problems for it to solve along the way and it will use algorithms that you have specifically given it to solve those problems. But the instructions must be completed, in order. Just like a child completing a test, if you haven’t given it the algorithm to solve the problem in a language it understands, it will fail to solve the problem correctly. And just like a teacher marking a test, when you run the program and see what went wrong (debugging), you’ll be able to see what they couldn’t understand and try to change the algorithm so that it works.

Plenary

Today, we have looked at what an algorithm is, what debugging is and what a program is. We have compared algorithms and programs and found that, while there is some overlap between what they are, programs are lists of instructions that a computer understands whereas algorithms are step-by-step ways to solve specific problems. A program may contain one, none or more algorithms.

Next Steps

In order to teach basic computer programming, your next step is to dive in and have a go. You actually need to spend some time doing it. I know you are unbelievably busy, but the simple fact is that you can’t teach programming if you’ve never had a go at it yourself. I’d recommend some dedicated staff training time, either as all or part of a training day or even as all or part of a staff meeting. But here’s the helpful part – it doesn’t have to be difficult at all and can even be quite fun.

Wherever you are, take care, and I’ll see you very soon.

James

2 Responses

  1. Thanks James, I wasn’t sure about this before but I think I get it now. So an algorithm is just the way of solving a particular problem but a program is a list of computer instructions?

Leave a Reply

Your email address will not be published.