My Blog
Articles related to programming, computer science, technology and research.

22/04/2016 Categories: Programming. Comments Off on Algorithm



An algorithm is a finite sequence of step by step, discrete, unambiguous instructions for solving a particular problem.


Algorithm is a step-by-step procedure for solving a particular problem.


An algorithm is an ordered set of unambiguous executable steps, defining a terminating process.


An algorithm, named after 9th centaury Persian mathematician al-Khowarazmi, is simply a set of rules for carrying out some calculation, either by hand, or, more usually, on a machine.


An algorithm is like a recipe. It lists the steps involved in accomplishing a task. It can be defined in programming terms as a set of detailed, unambiguous and ordered instructions developed to describe the processes necessary to produce the desired output from the given input.


The algorithm is written in simple English and is not a formalized procedure, however to be useful there are some principles which should be adhered to. An algorithm must:

  1. Be precise and unambiguous
  2. Give the correct solution in all cases and
  3. Eventually end.


Algorithms can be represented in different ways. They are:

1) Natural languages

2) Pseudocode

3) Flowcharts

4) Control tables




Pseudocode is easy to read and write, as it represents the statements of an algorithm in English. Pseudocode is really structured English. It is English which has been formalised and abbreviated to look very like a high-level computer language.


There is currently no standard pseudocode. Different textbook authors seem to adopt their own special techniques and set of rules, which often resemble a particular programming language. But as a guideline, try the following conventions:

  1. Statements are written in simple English.
  2. Each instruction is written on a separate line.
  3. Keywords and indentation are used to signify particular control structures.
  4. Groups of statements may be formed into modules and that group given a name.


If a programmer uses words and phrases in his or her pseudocode that are in line with basic computer operations, then the translation from the pseudocode algorithm to a specific programming language becomes quite simple.


We could break down the computers operations into six basic operations and represent these operations in pseudocode. Each operation can be represented as an English instruction with keywords and indentation to signify a particular control structure:


  1. A computer can receive information – when a computer is required to receive information or input from a particular source, whether it is a keyboard, disk or other source, the verbs Read and Get can be used



  1. A computer can put out information – when a computer is required to supply information or output to a device the verbs Print, Write or Put could be used



  1. A computer can perform arithmetic – most programs require the computer to perform some sort of mathematical calculation, or formula. You could use actual mathematical symbols or the words for those symbols



  1. A computer can assign a value to a piece of data – there are many cases where a programmer will need to assign a value to a piece of information. Firstly to give data an initial value in pseudocode the verbs, Initialise or Set can be used. Secondly to assign a value as a result of some processing, the symbol “=” is written. Thirdly, to keep a piece of information for later use the verbs Save or Store could be used



  1. A computer can compare two pieces of information and select one of two alternatives – an important ability is the comparison of two pieces of information and then as a result of the comparison select on of two alternate actions. To represent this operation in pseudocode the keywords IF, THEN and ELSE can be used



Note the use of indentation to emphasize the THEN and ELSE options and the use of the delimiter ENDIF to close the operation.


  1. A computer can repeat a group of actions – when there is a sequence of steps which need to be repeated, the keywords DOWHILE and ENDDO could be used



Once again note the use of indentation. It is easy to read where the loop starts and ends. Alternatives to the above could be WHILE and ENDWHILE.




Problem: Write an algorithm for adding two integers.






Problem: Write an algorithm to find the greatest number among two integers.





Related Links:

Scroll Up