💻 Computers

Al-Khwarizmi and algorithms

Numbered steps linked by arrows all the way to the star

📖 In short

An algorithm is a list of steps in order that we follow to get a task done: a cake recipe is an algorithm, the way we wash our hands is an algorithm, and column addition is an algorithm. This word, used by programmers all over the world, comes from the name of a Muslim scholar who lived in Baghdad more than a thousand years ago: Muhammad ibn Musa al-Khwarizmi.

🤩 Did you know?

  • The word “algorithm” that programmers use comes from al-Khwarizmi's name.
  • Al-Khwarizmi helped spread digits and zero around the world, and without zero there would be no binary system.
  • When you search the internet, you're using an algorithm that sorts millions of pages for you in less than a second.
  • Even solving a Rubik's Cube has algorithms that speed solvers learn by heart.

🔎 Find out more

🌟 Who was al-Khwarizmi?

Al-Khwarizmi lived in the 9th century and worked at the “House of Wisdom” in Baghdad, the biggest library and center of learning of his time. He wrote about arithmetic, astronomy and geography, and explained how to calculate with decimal digits, including zero.

🔍 From his name to the computer

Al-Khwarizmi's books were translated into Latin, and in Europe his name became “Algoritmi”; then the word came to mean a step-by-step way of solving something. And the word “algebra” comes from the title of his book “Al-jabr wa-l-muqabala”.

💡 Order matters a lot

A computer carries out steps in the order we write them, without thinking about whether it makes sense. If we told it “drink the juice” before “squeeze the orange”, it wouldn't see the mistake! That's why programmers write their steps carefully.

🎯 Finding the mistake

When a program doesn't work the way we want, we check the steps one by one until we find the wrong one and fix it. This is called “debugging”, and it's a normal part of every programmer's work, even the best.

🧭 The dictionary algorithm

To find a word in a dictionary, you don't read every page: you open it in the middle, and if your word comes before, you look in the first half, otherwise in the second, and repeat. This clever algorithm is called “binary search”, and it finds the word amazingly fast.

🌈 More than one way

One task can have several algorithms: some faster, some easier. A skilled programmer picks the best one, just as you pick the shortest way to school.

📊 See how it works

Flowchart for crossing the road: look right and left; if the road is clear, cross, else wait and look again
A flowchart of the algorithm for crossing the road: a question, and if the answer is “no”, we wait and look again.

📚 Key words

Algorithm
Steps in order to get a task done
Flowchart
A drawing showing the steps, the questions and the arrows between them
Debugging
Finding the wrong step and fixing it

🧪 Try it at home

Write the algorithm for making a glass of chocolate milk, then give it to one of your parents to follow exactly, without adding anything. Did you forget a step like “open the tin”?

🧩 Test yourself

1 In which city did al-Khwarizmi work?

2 What is an algorithm?

📚 Read next

🎮 Try it yourself