What Is an Algorithm? A Beginner-Friendly Explanation
By the BrainSnail editorial team. How these articles are written and checked, and how to tell us when one is wrong.
What is an algorithm, and why does the word appear so often when people talk about computers? An algorithm is a clear sequence of steps for completing a task or solving a problem. You use algorithm-like thinking in ordinary life too, whenever you follow a recipe, sort a list, or choose what to do based on a condition.
The idea in simple terms
An algorithm takes some starting information, follows defined instructions, and produces a result. A computer program may contain many algorithms working together. One algorithm could sort names into alphabetical order, another could search for a particular item, and another could decide what happens after you press a button.
The steps need to be precise enough to follow. Telling a computer to 'sort these numbers nicely' is not useful because 'nicely' is vague. Telling it to compare values and move smaller ones before larger ones gives a process that can be carried out. This precision is one reason algorithm design teaches careful thinking about what a problem actually requires.
When you ask what an algorithm is, remember that an algorithm is not the same thing as a programming language. The algorithm is the method. Code is one way to express that method so a computer can perform it. The same basic algorithm can often be written in several programming languages.
Algorithms can make choices and repeat steps
Many algorithms are more than a straight list from step one to step ten. They can include conditions. A navigation app, for example, might choose one action if a road is open and another if it is closed. A quiz can check whether an answer is correct and then follow different steps depending on the result.
Algorithms can also use loops, which repeat instructions until a condition changes or a set number of repetitions is reached. A program might inspect every item in a list one by one. Instead of writing the same instruction hundreds of times, the algorithm describes the repeated pattern once.
This is useful for understanding an algorithm because real problems often contain both choices and repetition. The power comes from arranging simple instructions so they handle many possible inputs without needing a completely new plan each time.
How to judge a useful algorithm
When comparing methods, check a few basic questions:
- •Does the algorithm produce the correct result?
- •Are the steps clear and unambiguous?
- •Does it stop when the task is complete?
- •How much time does it need as the input grows?
- •How much memory or other resources does it use?
Algorithms also appear in problems where there is no single perfect answer. A route-finding method may search many possible paths and choose one that is short enough to be useful, while a recommendation system may rank options using several signals. In those cases, designers must decide what counts as a good result. That matters when you study an algorithm because the steps reflect human choices about goals, priorities, and trade-offs. An efficient method can still produce poor outcomes if the problem was defined badly or the input data is incomplete.
The takeaway
An algorithm is a defined method for turning a problem into a sequence of workable steps. Algorithms can include decisions, loops, comparisons, and calculations, and they can be expressed in code or explained before any code is written. Focus on the method first, then ask whether it is correct, clear, and efficient for the job.