Background reading · Technology
Algorithms: instructions a computer can follow
What an algorithm is, the three building blocks of every program, and the woman who wrote the first one in 1843.
An algorithm is a set of steps that solves a problem or completes a job. A recipe is an algorithm. So are the directions to your friend's house. Computers are very fast, but they are not clever. They do exactly what they are told, in exactly the order they are told. So the steps have to be precise.
Try telling a robot
Ask a friend to make a sandwich by following your written steps exactly. 'Put butter on the bread' sounds fine, until they put the whole block of butter on top of the unopened bag. Humans fill the gaps with common sense. Computers cannot. Writing algorithms means leaving no gaps.
The three building blocks
Almost every program ever written, from a phone game to a Mars rover, is built from these three ideas combined in clever ways.
The first programmer
In the 1830s, English inventor Charles Babbage designed a mechanical computer called the Analytical Engine. It was never finished, but mathematician Ada Lovelace studied it closely. In 1843 she published notes that included a step-by-step method for the machine to calculate a tricky series of numbers. Many people call it the first computer program. She also imagined that such machines might one day make music, not just do sums.
Same problem, different algorithms
There is usually more than one way to solve a problem. To find a word in a dictionary, you could start at page one and check every word, or open it in the middle and jump towards the right letter. Both work, but one is far faster. Good programmers look for the algorithm that is clear, correct and efficient.
Algorithms in your game
Your Scratch game is an algorithm. Before you code, write it in plain words, called pseudocode, and check it with a partner. It is much easier to fix a mistake on paper than in fifty blocks of code.
Sources and further reading
- Ada Lovelace (Computer History Museum) ↗
- Algorithms (Computer Science Field Guide) ↗
- Kidbots (CS Unplugged) ↗
Written for Kōkiri Learn students in our own words. Check facts against the sources.