Introduction to Algorithms - Need of Algorithms

 

Suppose you have a problem that can be solvable by you or by a machine (Computer), so you will have to do a certain procedure to solve that problem. The instruction or the command written in a simple language of the procedure is known as an algorithm. An algorithm is simply a set of well-defined steps that can be followed to produce a different set of outputs based on some inputs. An algorithm can be a tea recipe.

1. Boil water in a pan.

2. Add sugar and tea leaves in it and boil it for 4-5 minutes.

3. Add milk and boil it for 7-8 minutes.

4. Turn off the gas and strain tea in cups.

5. Enjoy the tea.

The inputs are water, sugar, tea leaves, pan, and fire and the output is tea.

The algorithm is (Definiteness) clear and unambiguous, (Effectiveness) a possible result and terminate after a finite number of steps. It means Donald Ervin Knuth said correctly.

Algorithms are typically written in pseudocode, or a combination of your native language and one or more programming languages, before being implemented in a program.

If you want to write a program, of any language C, C++, Java, and Python, you have to write an algorithm or pseudocode first, and it should be in a bullet numbered form. So while making the program, you exactly know what is the logic behind it if it is in a numbered form.

Note: The algorithm should be very simple but few of you read the coreman book and It is not easy to understand the logic behind algorithm in that book. But most of the professors and researchers on this earth, read and teach coreman book and deal with that complexity of the algorithm. 

Post a Comment

0 Comments