## ALGORITHMS.

Assuming that you have basic knowledge about computer like when it was made,types of computer and operating system,hardware parts of computer,inventor of computer,etc,i am starting a new but important topic "ALGORITHM".

## What is an Algorithm?

An algorithm is a part of the plan for the computer program. Infact ,an algorithm is an effective procedure for solving a problem in a finite number of steps.
It is effective,which means that an answer is found and it has a finite number of steps.A well-designed algorithm will always provide an answer,it may not be the desired anwser but there will be an answer.A well-designed algorithm is also guaranteed to terimnated.
An Algorithm can also be defined as "finite step by step list of well defined instructions for solving a particular problem".
We always need to write algorithm for making different data structure operations.So lets understand what algorithm consist of.
In first part of algorithm we tell the purpose of algorithm.It lists for variables and input data.The second part is a list of steps.
The steps in algorithm are executed one after the other.Control may be transferred to step 'n' by using statement like 'Go to step n'.The exit and stop statements completes the algorithm.The data may be assigned to variables by using read statement and it is displayed by write or print statement.
Today,all the daily computer applications you use,someone might once have written algorithm for it which worked successfully and its result is in our hand.
Google,Facebook,Twitter,Bing,Yahoo,MSN ,etc,all are created and working successfully as their base(algorithm) had worked correctly.So,before any programmer start making something(own application),he/she should first make the algorithm as it is related to many factors like process execution time,results,etc.

#### General syntax of algorithm is given below:

 ALGORITHM 1: Purpose of algorithm and input data and variables used. Start Step 1: ……………………………………………………… Step 2: ………………………………………………………             :             : Step n: ……………………………………………………………. Stop or Exit.

### Different Ways Of Stating Algorithm.

Algorithm may be represented in various ways.There are four ways of stating algorithms.There steps are as follows:
• Step-form.
• Pseudo-code.
• Flow chart.

#### Step-Form Algorithm:

In the step form representation,the procedure of solving a problem is stated with written statements.Each statement solves a part of problem and these together completes the solution.The step-form uses just normal language to define each procedure.Every statement ,that defines an action,is logically related o preceding statement.

#### Pseudo-code:

The pseudo-code is a written form representation of the algorithm.However,it differs from the step form as it uses a restricted vocabulary to define its action of solving the problem.One problem with human language is that it can seem to be imprecise.But the pseudo-code,which is in human language,tends towards more precision by using a limited vocabulary.

#### Flow chart and Nassi-Schneiderman:

Flow chart and Nassi-Schneiderman are graphically oriented representation forms.They use symbols and language to represent sequence,decision and repetition actions.
Standard flowchart symbols are given below:

#### Key Features of an Algorithm and the Step-form.

Here is an example of an algorithm,for making a pot of tea.
1. If the kettle does not contain water,then fill the kettle.
2. Plug the kettle into power point and switch it on.
3. If the teapot is not empty,then empty the teapot.
4. Place tea leaves in teapot.
5. If the water in the kettle is not boiling,then go to step 2.
6. Switch off the kettle.
7. Pour water from the kettle into the teapot.
It can be seen that the algorithm has a number of steps and that some steps(1,3 and 5) involve decision making and one step(5 in case) involves repetition,in this case the process of waiting for the kettle to boil.
From this example,it is evident that algorithms show there three features:
Therefore, an algorithm can be stated using three basic constructs : sequence, decision and repetition.

• • • 