What Is an Algorithm? Recipes for Computers
Step-by-step instructions that solve problems
Step-by-step instructions that solve problems
You follow algorithms every day without calling them that. Getting dressed, making a sandwich, finding a book in a library. Click each example to see the algorithm behind it.
The same steps in a different order produce different results. Click the steps in the right order to complete the algorithm. Get it wrong and the result is a mess.
Find the number 73 in a sorted list. Linear search checks each number one by one. Binary search jumps to the middle and eliminates half each time. Watch them race.
Every piece of technology you use runs algorithms.
PageRank algorithm: rank pages by how many other pages link to them. More links from important pages = higher rank. Billions of pages, ranked in milliseconds.
Dijkstra's algorithm: find the shortest path through a road network. It explores outward from your location, always expanding the shortest known route first.
Recommendation algorithms decide what you see in your feed. They predict what you will engage with based on what similar users liked. Billions of decisions per second.
The word "algorithm" comes from the name of the 9th-century Persian mathematician Muhammad ibn Musa al-Khwarizmi, whose book on arithmetic introduced the Hindu-Arabic number system to Europe. His name, latinized to "Algoritmi," became the word we use today.
You've learned that algorithms are just step-by-step instructions. Every app, search engine, and game runs on algorithms. The key insight: break any problem into small, clear steps, and a computer can solve it.
A recipe is an algorithm: specific steps in a specific order producing a specific result. "Preheat oven, mix flour and sugar, bake 20 minutes." Computers follow the same idea.
Put on socks then shoes works. Shoes then socks does not. Algorithm steps must be in the right order to produce the correct result.
Every algorithm takes input (ingredients) and produces output (a cake). A search algorithm takes a query and outputs ranked results.
Finding a word in a dictionary by reading every page works but is slow. Opening to the middle and narrowing down is fast. Both are algorithms. One is better.
Put your new knowledge into practice!