What Is an Algorithm?  Definition & Examples
An algorithm is a set of steps for accomplishing a task or solving a problem. Typically, algorithms are executed by computers, but we also rely on algorithms in our daily lives. Each time we follow a particular stepbystep process, like making coffee in the morning or tying our shoelaces, we are in fact following an algorithm.
In the context of computer science, an algorithm is a mathematical process for solving a problem using a finite number of steps. Algorithms are a key component of any computer program and are the driving force behind various systems and applications, such as navigation systems, search engines, and music streaming services.
What is an algorithm?
An algorithm is a sequence of instructions that a computer must perform to solve a welldefined problem. It essentially defines what the computer needs to do and how to do it. Algorithms can instruct a computer how to perform a calculation, process data, or make a decision.
The best way to understand an algorithm is to think of it as a recipe that guides you through a series of welldefined actions to achieve a specific goal. Just like a recipe produces a replicable result, algorithms ensure consistent and reliable outcomes for a wide range of tasks in the digital realm.
And just like there are numerous ways to make, for example, chocolate chip cookies by following different steps or using slightly different ingredients, different algorithms can be designed to solve the same problem, with each taking a distinct approach but achieving the same result.
Algorithms are virtually everywhere around us. Examples include the following:
 Search engines rely on algorithms to find and present relevant results as quickly as possible.
 Social media platforms use algorithms to prioritise the content that we see in our feeds, taking into account factors like our past behaviour, the popularity of posts, and relevance.
 With the help of algorithms, navigation apps determine the most efficient route for us to reach our destination.
How do algorithms work?
Algorithms use a set of initial data or input, process it through a series of logical steps or rules, and produce the output (i.e., the outcome, decision, or result).
If you want to make chocolate chip cookies, for instance, the input would be the ingredients and quantities, the process would be the recipe you choose to follow, and the output would be the cookies.
Algorithms are eventually expressed in a programming language that a computer can process. However, when an algorithm is being created, it will be people, not a computer, who will need to understand it. For this reason, as a first step, algorithms are written as plain instructions.
It is important to keep in mind that an algorithm is not the same as a program or code. It is the logic or plan for solving a problem represented as a simple stepbystep description. Code is the implementation of the algorithm in a specific programming language (like C++ or Python), while a program is an implementation of code that instructs a computer on how to execute an algorithm and perform a task.
Instead of telling a computer exactly what to do, some algorithms allow computers to learn on their own and improve their performance on a specific task. These machine learning algorithms use data to identify patterns and make predictions or conduct data mining to uncover hidden insights in data that can inform business decisions.
Broadly speaking, there are three different types of algorithms:
 Linear sequence algorithms follow a specific set or steps, one after the other. Just like following a recipe, each step depends on the success of the previous one.
 Conditional algorithms make a decision between two actions. Instead of executing all steps sequentially, a conditional algorithm involves making choices based on specific scenarios or input data. It uses “if/then” statements to determine what to do.
 For example, in the context of a cookie recipe, you would include the step “if the dough is too sticky, you might need to refrigerate it”.
 Looping algorithms repeat a specific set of instructions multiple types until either a certain condition is met or a predefined number of repetitions has been completed. The purpose of looping algorithms is to efficiently perform repetitive tasks without the need to write the same instructions multiple times.
 For example, a looping algorithm could be used to handle the process of making multiple cookies from a single batch of dough. The algorithm would repeat a specific set of instructions to form and bake cookies until all the dough has been used.
Examples of algorithms
Algorithms are fundamental tools for problemsolving in both the digital world and many reallife scenarios. Each time we try to solve a problem by breaking it down into smaller, manageable steps, we are in fact using algorithmic thinking.
In mathematics, algorithms are standard methods for performing calculations or solving equations because they are efficient, reliable, and applicable to various situations.
Navigation systems are another example of the use of algorithms. Such systems use algorithms to help you find the easiest and fastest route to your destination while avoiding traffic jams and roadblocks.
Other interesting articles
If you want to know more about ChatGPT, AI tools, fallacies, and research bias, make sure to check out some of our other articles with explanations and examples.
ChatGPT
Fallacies
Frequently asked questions about algorithms
 What is an algorithm in computer science?

In computer science, an algorithm is a list of unambiguous instructions that specify successive steps to solve a problem or perform a task. Algorithms help computers execute tasks like playing games or sorting a list of numbers. In other words, computers use algorithms to understand what to do and give you the result you need.
 Are algorithms the same as artificial intelligence (AI)?

Algorithms and artificial intelligence (AI) are not the same, however they are closely related.
 Artificial intelligence is a broad term describing computer systems performing tasks usually associated with human intelligence like decisionmaking, pattern recognition, or learning from experience.
 Algorithms are the instructions that AI uses to carry out these tasks, therefore we could say that algorithms are the building blocks of AI – even though AI involves more advanced capabilities beyond just following instructions.
 Are algorithms the same as computer programs?

Algorithms and computer programs are sometimes used interchangeably, but they refer to two distinct but interrelated concepts.
 An algorithm is a stepbystep instruction for solving a problem that is precise yet general.
 Computer programs are specific implementations of an algorithm in a specific programming language. In other words, the algorithm is the highlevel description of an idea, while the program is the actual implementation of that idea.
 Why do we need algorithms?

Algorithms are valuable to us because they:
 Form the basis of much of the technology we use in our daily lives, from mobile apps to search engines.
 Power innovations in various industries that augment our abilities (e.g., AI assistants or medical diagnosis).
 Help analyse large volumes of data, discover patterns and make informed decisions in a fast and efficient way, at a scale humans are simply not able to do.
 Automate processes. By streamlining tasks, algorithms increase efficiency, reduce errors, and save valuable time.
Cite this Scribbr article
If you want to cite this source, you can copy and paste the citation or click the ‘Cite this Scribbr article’ button to automatically add the citation to our free Reference Generator.