In this article, you will learn how to represent an algorithm using a pseudo code and elements of pseudo codes. Learning a programming language is not necessary to understand pseudo code, but knowing a programming language like C, Pascal, etc. help you understand the pseudo codes better.

## Algorithms Components

The algorithm has two part – **heading and the body. **See the table below for more information.

Notation | Description | |
---|---|---|

Heading | Algorithm <Name>(<parameter-list>) | has the name of the procedure and parameters |

Body | { } | two braces indicates block of statements |

### Example:

```
Algorithm Find_Max( A[n])
{
// A[n] is the list of unsorted numbers from which
// we need to find Max value.
max := 0;
for i := i to n do
if max >= A[i] then
{
max := A[i];
}
}
```

The above is sample algorithm to find max value from a list of numbers. The algorithm is written in pseudo code and contains lot of elements with their own notations.

## Notations

See the table below to understand each notation because you need them for writing algorithms.

Element Name | Notation | Description |

Comments | // | start with // till the end of line. |

Block | { } | indicate a block of statements. |

Identifier | dummy-variable | starts with a letter, variable data type is not defined. |

Assignments | <var> := <value> | assignments are done using := operator |

Logical Operators | and , or , not | can use logical operators in expressions. |

Relational Operators | >, <, <=, >=, != | relational operators are allowed |

Single Dimensional Array | A[j] | jth element of single dimensional array |

Multi-Dimensional Array | A[i, j] | represents a multidimensional array, (i, j) th element. |

While loop | while <condition > do { } | a while loop structure |

For loop | for var:= value 1 to value 2 step do { } | a for loop structure |

Conditional statement if – then | if <condition> then <statement> | if block of statements |

Conditional statement if – then – else | if <condition> then <statement> else <statement> | if – else block of statements |

Input | read | command to read input values |

Output | write | command to write output values |

Node | node = record { data type 1 data1; data type 2 data2; node *link; } | A compound data type make of other data types |