What is Algorithm

Distribute Education like Computer Geek

Definition of Algorithm

Some students say the definition of the algorithm is “the set of instructions applied on the input to get the output.” In this definition, the word “set” is wrongly placed. The definition of the set is “collection of elements” and the definition of an element is “any one of the distinct objects that belong to that set.” The word distinct is not applied in the algorithm. The algorithm has several steps, and there are many duplicates of the same step.

We have to write the same instruction several times.

  1. Start
  2. Calculator (int a, int b, int c)
  3. Enter a, b.
  4. c = a+b
  5. Print c
  6. c = a-b
  7. Print c
  8. c = a*b
  9. Print c
  10. c = a/b
  11. Print c
  12. End

You saw that we have written ‘Print c‘ in the 5th, 7th, 9th, and 11th instructions. But in the above definition, we have written that the “set” of instructions, meaning “print c” can come only once, which is not correct. This algorithm that we have written above is very basic, but it is also an algorithm, and it is absolutely correct, but it does not satisfy the “set” of instructions. One more thing to see is that if the algorithm has started, then there is also a ‘stop’. That means there will be an algorithm in a finite sequence.

So, the correct definition of an algorithm is “A step-by-step procedure for solving a specific type of problem. The problem can be solved manually or, more usually, on a machine.”

Examples of manual problems such as making tea

  1. Start
  2. Put flask on the gas
  3. Pour water, milk, and tea leaves
  4. Boil the mixture
  5. Add sugar
  6. Boil the mixture
  7. Tea is ready
  8. Stop

But we are interested in computational problems as we are computer engineers, so the definition is “an algorithm is a finite sequence of instructions that specify a sequence of operations to be carried out to solve a specific problem or class of problems.”

 
Father of Algorithmic Analysis

After a long period, Donald Ervin Knuth came. He was born on January 10, 1938, and is a computer scientist, mathematician, and professor emeritus at Stanford University. Knuth is known as the “father of algorithmic analysis.”

Donald Ervin Knuth
Donald Ervin Knuth reading “The Art of Programming”

He wrote three books, “The Art of Computer Programming 1, 2, and 3.” The algorithm is explained very well in that book, but his book is very complex. Not everyone understands. Those who consider themselves to be great programmers should read that book. Maybe their illusions will be broken.

Donald Ervin Knuth said that the above definition is absolutely fine, but it will add five more characteristics. These are –

  1. Input – There can be zero or more inputs such that there is no input in the program of hello world.
  2. Output – At least one output must come.
  3. Definiteness – Every instruction should be very clear and unambiguous. There should be no doubt or misunderstanding in the instruction.
  4. Effectiveness – Every instruction should be very basic and possible and result-giving.
  5. Finiteness – The algorithmic instruction must end after a finite number and also number of operations are finite. That is why we write the ‘End’ after the algorithm is over.

Test Yourself

Q1- What is the definition of Algorithm?

“An algorithm is a finite sequence of instructions that specify a sequence of operations to be carried out to solve a specific problem or class of problems”.

Characteristics –

  1. Input – There can be zero or more inputs such that there is no input in the program of hello world.
  2. Output – At least one output must come.
  3. Definiteness – Every instruction should be very clear and unambiguous. There should be no doubt or misunderstanding in the instruction.
  4. Effectiveness – Every instruction should be very basic and possible and result-giving.
  5. Finiteness – The algorithmic instruction must end after a finite number. That is why, we definitely write the ‘End’ after the algorithm is over.
Q2- Who is Donald Ervin Knuth?

Donald Ervin Knuth is known as the “father of algorithmic analysis”.

Q3- Can an instruction be used more than once in an algorithm?

Yes, instruction can be used more than once in an algorithm. 

 

Q4- “Algorithm is a set of instructions” is it correct?

No, Algorithm is not a set of instructions, the word ‘set’ is wrongly placed. The definition of the set is “collection of elements” and the definition of elements is “any one of the distinct objects that belong to that set”. The word distinct is not applied in the algorithm. 

Q5- If the algorithm has started, then there is also a _______.

Stop. 

BOOKS

Algorithm T H CoremanAlgorithm by Udit AgarwalAlgorithm Ellis HorowitzData Structure & Algorithm Made Easy Narasimha