Programming
What is An algorithm?
An algorithm is a precise, step-by-step set of instructions for solving a problem or completing a task. Recipes, search engines, and GPS routes all run on algorithms.
See it, don’t just read it.
Watch a 2-minute lesson with voice + animation that explains an algorithm.
Key things to understand
- 1It takes an input, follows a finite sequence of unambiguous steps, and produces an output.
- 2Good algorithms are correct (right answer) and efficient (fast, low resource use).
- 3The same problem can have many algorithms with different speed/memory trade-offs.
- 4They're the core of all software — sorting, searching, routing, recommending.
Frequently asked questions
- Is an algorithm the same as code?
- No. An algorithm is the idea or recipe; code is one way to express it in a particular programming language.
- What makes an algorithm good?
- Correctness (it always gives the right result) and efficiency (it uses little time and memory).
- What is Big O notation?
- A way to describe how an algorithm's time or memory grows as the input gets larger.