An algorithm can be defined as a finite set of stepwise instructions that should be followed to perform a specific task like solving a logical or a mathematical problem.
CHARACTERISTICS OF A GOOD ALGORITHM

Input It receives an input.

Generality It works on a set of inputs.

Definiteness The steps must be precisely defined.

Uniqueness The results of each step is uniquely defined and depends only on the input and the results of the previous steps.

Finiteness It stops after a finite number of instructions have been executed.

Output It produces the desired output.
WRITING AN ALGORITHM

It is written in an Englishlike language.

It should have an input.

You can use the syntax of the language if you are taking an example of a programming language.

You can include variables.

You can define mathematical expressions to calculate result.

You can refer to each step by a unique step number.

It should perform some action or produce an output.
An algorithm is logically represented by flowchart.