What's an Algorithm? Start With Three Numbered Cards
Put three cards marked 5, 2 and 4 on a table, then arrange them from smallest to largest. You've solved a tiny problem; an algorithm spells out the steps so someone else, or a computer, can solve it too.
An algorithm is a defined procedure for reaching a result. The National Institute of Standards and Technology dictionary describes it as a computable set of steps, meaning the instructions can be carried out systematically.
The information you start with is the input. The result is the output, and the algorithm explains how to get from one to the other.
What Is an Algorithm?
Give the computer an actual procedure
“Put the cards in order” states the goal, but leaves the method open. Here's one method that works for our three cards:
- Find the smallest card still in the unsorted group.
- Move it to the end of a new, ordered row.
- Repeat until the unsorted group is empty.
Starting with 5, 2 and 4, you choose 2 first, then 4, then 5. That repeated choice is the central idea behind selection sort, an algorithm for putting items in order.
The instruction to repeat is a loop. The check for an empty group tells the procedure when to stop, so it doesn't keep looking for a card that no longer exists.
A complete version also needs to handle ordinary surprises. If two cards both say 2, it must keep both; if there are no cards at the start, there's nothing to sort.
The method isn't the program
An algorithm can be described with words, a diagram or mathematical notation. A program is an implementation: instructions written so a computer can carry out the method, along with whatever else the application needs to do.
Two programmers can implement the same algorithm in different programming languages. One version might contain a coding mistake even though the underlying procedure is sound.
There can also be several algorithms for the same job. The simple card method is easy to follow, but repeatedly searching all remaining items becomes expensive as the pile grows.
Computer scientists compare how methods use time and memory, the computer's working storage. The best choice depends on the task and the size and shape of the input, not just whether an algorithm has a clever name.
- Make LEDs blink and sensors report in an afternoon with more than 22 guided lessons.
- Start with no soldering: everything plugs into the breadboard.
- See how code controls real hardware, the first step toward understanding any device.
Security depends on precise steps, too
Encryption uses algorithms to transform readable information into protected data that can be recovered with the right key. The Advanced Encryption Standard, or AES, is one familiar example: the procedure is public, while the key must remain secret.
A hash function performs a different job: it calculates a compact value from data. Security tools can compare that value with a trusted reference to help check whether a file has changed, as reflected in NIST's hash-function definitions.
Hashing isn't a way to encrypt a document and later unlock it. The purpose of the algorithm matters just as much as the fact that it uses mathematics.
An algorithm also doesn't have to involve artificial intelligence, the broad field of systems that perform tasks such as recognizing patterns or generating language. Our card sorter follows a procedure without learning anything from examples.
And a procedure can faithfully produce an unhelpful result if its goal is poorly chosen. A rule that flags every late-night login, for instance, may catch intruders and annoy the night shift in equal measure.
Cryptographic Algorithms: The Different Jobs Behind “Secure”

Hash Functions: Small Outputs With a Big Job

Work Factor: Making Each Password Guess Cost More

QUOTE:
"Amateurs hack systems, professionals hack people."
