 In Progress
Lesson 1 of 43
In Progress

# What is an Algorithm?

An Algorithm is a sequence of steps designed for programming a computer to solve a specific problem normally by using the machine.

In simple terms –  An algorithm is a finite set of instructions that, if followed, accomplishes a particular task.

The reference to “instructions” in the definition implies that there is something or someone capable of understanding and following the instructions given.

We call this a “computer,” keeping in mind that before the electronic computer was invented, the word “computer” meant a human being involved in performing numeric calculations. Nowadays, of course, “computers” are those ubiquitous electronic devices that have become indispensable in almost everything we do.

Note, however, that although the majority of algorithms are indeed intended for eventual computer implementation, the notion of algorithm does not depend on such an assumption.

As examples illustrating the notion of the algorithm, we consider in this section three methods for solving the same problem: computing the greatest common divisor of two integers. These examples will help us to illustrate several important points:

• The non-ambiguity requirement for each step of an algorithm cannot be compromised.
• The range of inputs for which an algorithm works has to be specified carefully.
• The same algorithm can be represented in several different ways.
• There may exist several algorithms for solving the same problem
• Algorithms for the same problem can be based on very different ideas and can solve the problem with dramatically different speeds.

Next you have to learn what are the steps involved in designing an Algorithm ?

These are steps involved in designing a Algorithm :-

STEP 1 –  Defining the  goal that has to be accomplished.
STEP 2 – Figure out the steps using which the goal has to be accomplished and list down the steps clearly

If the above two steps are orderly performed, there it is …. An Algorithm is Designed !

Complicated ?? Lets simplify it using an Example,

Say supposing we have a dozen mango’s and we have to find the biggest amongst them.

Now, lets design an algorithm for achieving the same using the steps involved in designing an algorithm .

STEP 1

Finding the biggest mango (goal that has to be accomplished)

STEP 2

Step c) pick a mango from basket-A

Step d) if it is first time that the mango is picked then place it in basket-C

Step e) if it is not the first pick, then compare the picked mango with the one which is placed in basket-C

Step f) if it weighs less than the one in basket-C, then put it into the basket-B

Step g) if it weighs high, then place it in  basket-C and place the one which you have already placed in basket-C into basket-B

Step h) if there are mangoes still remaining in basket-A then repeat from step c. else check the basket-C you have a biggest one.

Go grab it and eat it, and I call this as mango Eating Algorithm.

Is it simple ?

Then you have to definitely learn the

CRITERIA THAT ANY ALGORITHM SHOULD SATISFY.

We can specify the algorithm in TWO ways :-

1.NATURAL LANGUAGE

NATURAL LANGUAGE as in English like statements but, if we use this representation we must make sure that the resulting instructions are specific

2. PSEUDO CODE

PSEUDOCODE LANGUAGE  is a combination of both natural language and programming language .  A pseudo code is usually more precise than natural language.