Sitemap
Dev Genius

Coding, Tutorials, News, UX, UI and much more related to development

Understanding Algorithms

3 min readDec 28, 2024

--

Press enter or click to view image in full size

Today, I am starting on a new topic that I have not written about previously. We are talking about Algorithms.

It is 2025… You hear this word almost everyday, don’t you?

But… What is an Algorithm? What does it do? Let’s have a look.

It can simply be said as this.

An algorithm is a set of well-defined instructions with a logical and systematic procedure, which can be used to solve a problem.

An Algorithm is used to describe the process of completing a task.

They are used in different fields including mathematics, computer programs and day-to-day lives. Several operations like additions and subtractions also can be used while executing an algorithm. Algorithms are widely used in all areas of Information technology.

Characteristics of a Good Algorithm

Just like anything in this world, not all algorithms are equal and the quality matters. However, a good algorithm can easily stand out from the rest if it fulfills the following criteria. Let’s have a look at them.

  • Clear and Logical Steps: A good algorithm should have a easy to follow, well-defined steps. Each step of it must be clear and define the action to be done leading only to one meaning. It should be unambiguous.
  • Independence from Programming Language: This is one of the most important factors. An algorithm must always be universal, and not specific to any programming language. To be clear, the steps of an algorithm should always be free of any specific syntax or features that are unique to a programming language.
  • Defined Inputs: A good algorithm should have zero or more clearly defined inputs. These inputs can be numbers, strings or any data type.
  • Expected Outputs: If you got inputs, that means you should have outputs. Simple logic. A good algorithm should produce one or more defined outputs. Those outputs should match with the results expected.
  • Finiteness: Most importantly, a good algorithm must have a finiteness to it. It should terminate after a finite number of steps and produce a result. If the algorithm does not terminate and keeps running, it is not an effective one.

Let’s have a look at an example of a simple, but a good algorithm that will fulfil the above qualities.

Get Chamod Kavishka’s stories in your inbox

Join Medium for free to get updates from this writer.

As the example scenario, I will add three numbers and get the total. The algorithm for this can be written as follows.

Example of a Good Algorithm

The above algorithm is a good algorithm with the characteristics mentioned earlier. It has clear steps, defined inputs that produce a result with a finite number of steps and terminates after a result is produced.

Representing Algorithms

Pseudocodes are a method that is often used to represent an algorithm. It provides high level and language independent way to represent an algorithm. The pseudocode for the above algorithm can be written as below.

Pseudocode for the Algorithm

The implementation of this in Python programming language can be done as below and get the results.

Press enter or click to view image in full size
Implementation of the Algorithm in Python
Implementation of the Algorithm in Python

Even with the use of the above simple example, I think it is clear how algorithms provide structure and clarity to problem-solving. Whether you are a programmer doing your job or a student solving a mathematical problem, understanding algorithms is a critical skill.

So, next time you follow a recipe, balance your budget, or write a program, remember that you are engaging with algorithms. It can be said that the algorithms are the backbone of problem-solving and innovation! Don’t you think so?

Keep up and connect with me! 🚀

The article may have come to an end, but there is always more to find, learn and achieve. Are you someone who thinks the same?

Stay updated with the latest trends, insights and exciting opportunities to grow professionally as well as personally. Let’s build a community of innovators and dreamers! Check the links below for more.

💼 LinkedIn: https://www.linkedin.com/in/uxchamod

📚 All Links: https://linktr.ee/uxchamod

--

--