Home » Algorithm Introduction

Algorithm Introduction

The computer program is a set of basic instructions to computer hardware. The computer hardware executes the instruction to carry out some tasks. The computer program is written using a blueprint called an algorithm. Each step in an algorithm has a clear meaning and performs a specific task.

An algorithm is any well-defined computational procedure that transforms one or more input values into one or more output values. Algorithms solve computational problems in a step-by-step manner.

For example, given a set of unsorted numbers as input, a sorting algorithm can sort the numbers in ascending or descending order as output.

Unsorted set
{ 2, 3, 5, 1, 8, 4, 7, 6}
Sorted list solved by sorting algorithm
{1, 2, 3, 4, 5, 6, 7, 8}

Characteristics of an Algorithm

Algorithms have some common characteristics that separate them from computer programs. A computer program implements the algorithm to solve a computer-based problem, but the reverse is not true.

  • Inputs
  • Output
  • Definiteness and Unambiguous
  • Finiteness
  • Effectiveness


An algorithm needs zero or more input values to compute the outputs. The size of the input values can be different for each instance of a problem solved by the algorithm.

Certain algorithms require that you place constraints on the input values. For example, an algorithm may need only positive integers values, the negative values are not allowed.


An algorithm processes the inputs and produces the desired output. The correct algorithm will always produce correct outputs for a computation problem.

Sometimes the output is a single value and sometimes it is an array of quantities.

Definiteness and Unambiguous

The algorithm must do definite operations or tasks that result in intermediate or final output. All procedures must contain unambiguous operations. If not, then the algorithm may not terminate or produce the wrong output and violate the finiteness characteristic or becomes an incorrect algorithm.


Finiteness means “having limits”. Every algorithm must end after a finite number of steps. It does not mean that an algorithm can take 100 steps to solve a problem because then you would not call that algorithm efficient.

An algorithm that terminates after reasonably finite steps maintains the finiteness characteristic.


The algorithm must perform basic operations that can be done using a pen or pencil on a piece of paper. This is called the effectiveness of the algorithm.

How to Represent an Algorithm?

Representing algorithm depends on the context. When you are writing a new algorithm then writing steps in plain English is suitable. The best way to represent an algorithm when writing a program is using a flowchart.

Three ways to represent an algorithm are

  1. Language ( e.g English)
  2. Flowcharts
  3. Pseudo Code (e.g C, C++)

Algorithms in this tutorial are written in pseudo codes.The pseudo codes are inspired by programming languages like C, but they are not executable codes. Instead a mere representation of algorithm.
You will learn more about pseudo codes in future lessons.