What Is an Algorithm?

In simple terms, an algorithm is:
"A set of clear, structured rules designed to achieve a specific goal."

Different sources might phrase it differently, but the core idea remains the same.

More formally, an algorithm is:
"A step-by-step process used to solve a problem logically and systematically."

Fun fact:

The word algorithm comes from the name of a Muslim mathematician, Abu Ja'far Muhammad ibn Musa Al-Khwarizmi (780–846 AD), whose work greatly impacted mathematics and science.


Why Are Algorithms Important?

Algorithms play a vital role in many areas, including:

  • The heart of computer science: Algorithms are the backbone of every software and application we use today.
  • Everyday life: Like following a recipe, sewing a dress, or assembling a car—any task with a clear set of instructions is basically an algorithm.

In short, algorithms aren’t just for computers; we use them all the time without even realizing it!

Depending on the situation, we can represent algorithms in different ways:

  • Natural language (like English or Indonesian):
    Writing algorithms in plain language is easy but can sometimes lead to confusion if instructions aren't crystal clear.
  • Flowcharts:
    Visual diagrams that map out the steps. Great for simple processes, but can get complicated if the flow is too long.
  • Pseudo-code:
    A middle ground between natural language and real programming code. It's often used by programmers because it looks clean and is easy to translate into actual code later.

A Simple Example of an Algorithm:

Using Natural Language

Here’s an algorithm to find the largest of three numbers:

  1. Set the first number as the maximum (Max).

  2. Compare the second number to Max.

  3. If the second number is larger, update Max to the second number.

  4. Compare the third number to Max.

  5. If the third number is larger, update Max to the third number.

  6. Max now holds the largest number.

Example:

  • A = 3, B = 2, C = 1
  • Max = A (3)
  • Is B > Max? No.
  • Is C > Max? No.
  • Final Max = 3 (the largest number).


Using a Flowchart:

Using Pseudo-code:

--


What Makes a Good Algorithm?

A good algorithm should:

  • Be well-documented for easy use, maintenance, and updates.
  • Clearly explain each step so it's easy to follow.
  • Be unambiguous—each instruction must have only one meaning.
  • Terminate after a certain number of steps (it must eventually end).

The Key Aspects of an Algorithm

Here are five important qualities every algorithm should have:

  1. Finiteness:
    It must always come to an end after a finite number of steps.

  2. Definiteness:
    Every step must be clearly and precisely defined.

  3. Input:
    It may accept zero or more inputs to start the process.

  4. Output:
    It must produce at least one output (a result).

  5. Effectiveness:
    Every operation must be basic enough to be carried out exactly and efficiently.


Final Thoughts

Algorithms are everywhere, shaping not just computer programs but everyday activities too. By understanding how algorithms work, you can solve problems more efficiently—whether you’re coding a new app or just figuring out the fastest way to organize your day.

References: