Menu

Computational Thinking

Algorithmic Thinking

Algorithmic thinking means deciding on the series of actions that will take you from the problem to the answer, putting those actions in the right order, and making each one precise enough that somebody else could follow it exactly and get the same result. An algorithm is a set of instructions, carried out in order, that produces a solution to a problem. The actions are the plan behind a solution; writing program code is one way of putting that plan into action, but the thinking itself comes first.

Precise steps, in the right order

Every step must say exactly what to do. "Find the average" is not a step, because two people could do it in two different ways. "Add the five test scores together, then divide the total by 5" is a step, because there is only one thing to do. Order matters just as much: dividing by 5 before the scores have been added up gives a nonsense answer.

Repetition and decisions

Algorithmic thinking also means spotting the parts of a solution that happen more than once, and the points where a choice has to be made.

Imagine a program that counts the free seats in a row at the cinema. The step "look at the next seat and add 1 to the total if it is free" is repeated for every seat. Repeating steps like this is iteration. After the count, the algorithm chooses between two messages: if the total is 10 or more it says "plenty of space", otherwise "almost full". Making a choice like this is selection. Writing the solution out as steps shows where each loop starts and ends, and exactly what each decision tests.

Why every step must be stated

A processor follows each instruction in turn, in the order it is given, and cannot fill in a gap. A person can guess what was meant; a processor cannot. Leaving out a step, or describing one vaguely, means the program will do the wrong thing, so algorithmic thinking forces you to be exact before any code is written.

Practise this

OCR GCSE Computer Science · Writing and Refining Algorithms