What is An Algorithm?

Stevie Militello
2 min readJun 13, 2023

--

We often hear the the phrase Algorithm but do we actually know what it means? A Leetcode or Hackerrank problem in an Algorithm, but what are an they exactly?

An easy way to describe an Algorithm is a set of steps or instructions for completing a task. With that in mind, you complete Algorithms every day. Ever made a list? Congrats, you’ve completed an Algorithm!

To dial in a little more, it is a set of steps a program takes to finish a task. Does this mean any code written can be considered an Algorithm? Yes, basically!

To dive deeper, what are Algorithms in relation to how we use them in coding? Well, they are solutions to common problems found in programming that people have collectively decided do the job well for the given task.

This is important because if you are unaware a solution exists, you may try to come up with one yourself, and your solution most likely won’t be as efficient as one that has been throughly reviewed by hundreds of people. Once you know it exists, you can also know when to apply it.

So how do we define an Algorithm? Well here are specifics:

  1. It must have a clearly defined problem statement, input, and output
  2. It has a set of steps that solve the problem. It’s definition must contain a specific set of instructions in a particular order. Also, each step must be explicitly clear, you shouldn’t have to break down the steps into further sub-steps.
  3. It should product a result, so there is a way to verify it works correctly. This result can be nothing, which can indicate it didn’t work. As long as it produces some result, we can understand its behavior.
  4. Lastly, it should actually complete and cannot take an infinite amount of time to do so.

These steps clearly define an Algorithm and give us a much more concrete idea of what an Algorithm is going forward. With this knowledge, we can begin to learn and apply Algorithms to give us a better understanding of code and programming in general.

--

--

Stevie Militello
Stevie Militello

Written by Stevie Militello

Art Teacher turned Software Engineer.

No responses yet