What is the difference between an Algorithm and a Method
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
People often use "algorithm" and "method" as if they mean the same thing, but they operate at different levels. An algorithm is a step-by-step procedure for solving a class of problems, while a method is usually a specific technique, implementation, or callable routine used inside a program or discipline.
The distinction matters because software design discussions become sloppy when those levels are mixed together. You can implement one algorithm with many different methods, and one method can be part of a larger algorithm.
What an Algorithm Is
An algorithm is a finite, well-defined sequence of steps that transforms input into output. It is abstract enough to exist independently of any programming language.
Examples:
- binary search
- Dijkstra's shortest-path algorithm
- merge sort
- Euclid's algorithm for greatest common divisor
What makes these algorithms is not the syntax. It is the problem-solving procedure and the guarantees it provides, such as correctness and time complexity.
Here is Euclid's algorithm in Python:
This is an implementation of an algorithm, but the algorithm itself is the mathematical process of repeatedly replacing the pair with (b, a mod b) until the remainder becomes zero.
What a Method Is
The word "method" is broader and depends on context.
In object-oriented programming, a method is a function associated with an object or class. In a more general technical discussion, a method can mean a particular way of applying a solution.
For example, in C# a method is a member of a class:
Add is a method. It is not an algorithm in the usual computer-science sense because it is just one program routine, not a general problem-solving procedure with its own complexity discussion.
How They Relate
A useful mental model is:
- algorithm answers "what procedure solves this problem"
- method answers "what concrete mechanism or callable unit are we using here"
For example, quicksort is an algorithm. A sort() method in a library may implement quicksort, mergesort, timsort, or something else depending on the runtime and data type.
So when you call a sorting method, you are using a method that internally applies an algorithm.
Why the Distinction Matters
This difference is important in code reviews and design work.
If someone says "we need a better method," they might mean:
- a cleaner API method
- a different numerical technique
- a faster algorithm
Those are not the same decisions. Choosing a better algorithm might reduce complexity from O(n^2) to O(n log n). Changing a method signature might improve readability without changing complexity at all.
Another Example: Search
Consider searching a sorted array.
Binary search is the algorithm:
- inspect the middle element
- discard half the search interval
- repeat until found or exhausted
A library call such as Collections.binarySearch(...) in Java is a method that exposes that algorithm through an API.
That distinction lets us talk clearly about:
- algorithmic complexity of binary search
- method usability of the library call
- implementation quality of the specific code
Common Pitfalls
- Calling every function or API routine an algorithm.
- Using "method" when the real topic is algorithmic complexity.
- Assuming an algorithm must be object-oriented because it is exposed through a method.
- Forgetting that the same algorithm can have multiple implementations.
- Confusing an implementation detail with the abstract procedure it implements.
Summary
- An algorithm is a step-by-step problem-solving procedure.
- A method is usually a concrete technique or a callable routine in code.
- Algorithms are language-independent; methods are often language or API specific.
- One method can implement an algorithm, but the two terms are not interchangeable.
- Keeping the distinction clear improves technical communication and design decisions.

