What Is an Algorithm?
An algorithm is a finite, ordered sequence of unambiguous steps that produces a specific output from a given input. The key properties:
Finite β terminates after a finite number of steps.
Well-defined β each step is unambiguous; no guessing.
Input/output β takes specified input(s) and produces specified output(s).
Effective β each step can actually be performed.
Algorithms predate computers by thousands of years. The long-division algorithm you learned in school is an algorithm. So is following a recipe, looking up a word in a dictionary, or finding your way home using turn-by-turn directions.
Where Does the Word "Algorithm" Come From?
The word algorithm comes from a person's name. In the 9th century CE, the Persian polymath Muhammad ibn Musa al-Khwarizmi worked at the House of Wisdom in Baghdad β the great library of the Abbasid Caliphate. Around 820 CE, he wrote a book on Hindu-Arabic numerals and computational methods. When translated into Latin in the 12th century, his name became Algoritmi, and the title Algoritmi de numero Indorum ("Al-Khwarizmi on the Hindu numerals") became the source of the modern word algorithm.
The same al-Khwarizmi gave us the word algebra from his other major work Al-Jabr. Two words from one mathematician β algorithm and algebra β both running everything from school math to modern computing.
What Are the Most Famous Algorithms in Math?
Euclidean Algorithm (GCD)
Find the greatest common divisor of two integers. Step:
Divide the larger by the smaller; note the remainder.
Replace the larger with the smaller; replace the smaller with the remainder.
Repeat until the remainder is 0. The previous remainder is the GCD.
Example. Find GCD(48, 18):
$$48 = 2 \times 18 + 12$$ $$18 = 1 \times 12 + 6$$ $$12 = 2 \times 6 + 0$$
GCD = 6.
First described in Euclid's Elements (c. 300 BCE) β the oldest still-used algorithm in the world.
Sieve of Eratosthenes (Primes)
Find all prime numbers up to a limit $N$.
List the integers from 2 to $N$.
Take the smallest unmarked number β it's prime.
Cross out all multiples of that prime.
Repeat with the next unmarked number.
The unmarked numbers at the end are all primes.
Named after Eratosthenes of Cyrene (c. 276βc. 194 BCE).
Long Division Algorithm
Standard step-by-step procedure for dividing one multi-digit number by another. The most-practised algorithm in elementary school math.
Newton's Method (Root Finding)
Find a numerical root of an equation $f(x) = 0$:
$$x_{n+1} = x_n - \frac{f(x_n)}{f'(x_n)}$$
Each iteration approaches a root quadratically. Used in calculators, financial software, and scientific computing.
What Are the Types of Algorithms?
In modern math and computer science, algorithms are classified by what they do.
Type | What It Does | Example |
|---|---|---|
Searching | Find an item in a collection | Binary search |
Sorting | Order items by some criterion | Quicksort, Merge sort |
Numerical | Compute with numbers | Newton's method, FFT |
Graph | Solve problems on graphs/networks | Dijkstra's shortest path |
Encryption | Protect data | RSA, AES |
Compression | Reduce data size | ZIP, JPEG, MP3 |
Machine learning | Learn patterns from data | Gradient descent |
Greedy | Make locally optimal choices | Huffman coding |
Divide and conquer | Break problem into subproblems | Mergesort, FFT |
Recursive | Define solution in terms of smaller cases | Factorial, Fibonacci |
Why Does the Algorithm Concept Matter? (The Real-World GROUND)
"Computer science is no more about computers than astronomy is about telescopes." β Edsger Dijkstra, 1986.
Algorithms run the modern world. Every interaction with a computer involves dozens or hundreds of algorithms running quietly in the background:
Google Search. PageRank algorithm (and its successors) rank billions of web pages by relevance β built on linear algebra and graph theory.
GPS routing. Dijkstra's shortest-path algorithm (1959) computes your driving route in milliseconds.
Online shopping recommendations. Collaborative filtering algorithms suggest items based on similarity to other users.
Credit card fraud detection. Machine-learning algorithms flag unusual transactions in real time.
Spotify and Netflix. Recommendation algorithms decide what plays next.
MRI scans and CT scans. The reconstruction of 3D images from cross-section measurements uses the filtered back-projection algorithm.
Cryptocurrencies. Every Bitcoin transaction is verified by the SHA-256 hash algorithm.
Air-traffic control. Conflict-detection and resolution algorithms keep aircraft safely separated.
DNA sequencing. Algorithms align billions of DNA reads against reference genomes.
Weather forecasting. Numerical weather prediction algorithms simulate the atmosphere on supercomputers.
The 20th-century theorist Alan Turing formalised what exactly counts as an algorithm in his 1936 paper on computability β defining the Turing machine as the abstract model of any algorithmic computation. The Turing machine is the theoretical basis of every computer that exists today.
A Worked Example
Find GCD(60, 48) using the Euclidean algorithm.
The intuitive (wrong) approach. A student tries to find common factors by listing them all:
Factors of 60: 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60. Factors of 48: 1, 2, 3, 4, 6, 8, 12, 16, 24, 48. Common: 1, 2, 3, 4, 6, 12. GCD = 12.
This works but takes forever for larger numbers (try GCD(1071, 462) by listing).
Why the algorithm is faster. The Euclidean algorithm needs at most a few divisions β even for huge numbers, it terminates in $O(\log n)$ steps.
The correct method (Euclidean algorithm).
$$60 = 1 \times 48 + 12$$ $$48 = 4 \times 12 + 0$$
GCD = 12. Two divisions instead of listing 12 factors of each number.
Check. $12 \times 5 = 60$ and $12 \times 4 = 48$ β 12 divides both β.
At Bhanzu, our trainers teach algorithms by showing the slow brute-force way first, then the algorithmic shortcut. Once a student feels the savings, they understand why algorithms are valued β not just what they are.
What Are the Most Common Mistakes With Algorithms?
Mistake 1: Confusing an algorithm with its implementation
Where it slips in: Treating the steps of long division as the algorithm, vs. one written-out solution of a specific problem.
Don't do this: Calling "23 Γ· 7" itself an algorithm.
The correct way: The long-division procedure β the general step-by-step method β is the algorithm. Applying it to "23 Γ· 7" is running the algorithm. The algorithm is the recipe; the worked example is dinner.
Mistake 2: Skipping the termination condition
Where it slips in: Iterative algorithms (Euclidean, Newton's method) require a stopping condition. Forgetting it means the algorithm never ends.
Don't do this: Run the Euclidean algorithm forever without checking "remainder is 0."
The correct way: Every iterative algorithm needs an explicit terminate when X condition. Without one, the algorithm doesn't terminate β and is therefore not a valid algorithm by definition.
Mistake 3: Confusing algorithm with heuristic
Where it slips in: Some procedures find good answers but not guaranteed answers β those are heuristics, not algorithms.
Don't do this: Calling a strategy that usually works an algorithm.
The correct way: An algorithm produces a correct answer for every valid input. A heuristic produces a good answer often. ChatGPT-style large language models are heuristic search procedures, not algorithms in the strict sense.
The Mathematicians Who Shaped Algorithms
Muhammad ibn Musa al-Khwarizmi (c. 780βc. 850, Persia/Baghdad) β His Latinised name Algoritmi gave us the word algorithm. His 9th-century book on computation with Hindu-Arabic numerals introduced systematic algorithmic methods to Europe.
Euclid of Alexandria (c. 325βc. 265 BCE, Greek Egypt) β His Elements contained the Euclidean algorithm for the GCD β the oldest algorithm still in active use today.
Alan Turing (1912β1954, England) β Formalised the concept of an algorithm in his 1936 paper On Computable Numbers, introducing the Turing machine as the abstract model of computation. The foundation of all modern computer science.
A Practical Next Step
Try these three before moving on to programming and data structures.
Use the Euclidean algorithm to find GCD(84, 36).
List the prime numbers from 2 to 30 using the Sieve of Eratosthenes.
Apply the long-division algorithm to compute $237 \div 8$.
Was this article helpful?
Your feedback helps us write better content