Shaswath Tarikere Srinivas

Algorithm

What is an algorithm ?

An algorithm is a clear set of steps to solve any particular problem. A good algorithm can not only be translated into code, but could also be executed by a person with no particular knowledge of the problem at hand.

An important point is you must specify exactly what you want the computer to do. The computer does not “know what you mean” when you write something vague, nor can it figure out an “etc.”, as an example.

The wrong way to write an algorithm is to throw some stuff on the page and then try to the make sense out of it later. After when it don’t work, we try to tweak the steps written initially on the paper until we get something that is respectable.

Steps to Devising an algorithm :

Devasing an algorithm

However, the “translate to code” comes only after you have an algorithm that you have tested by hand—giving you some confidence that your plan is solid before you build on it.

If you plan well enough and translate it correctly, your code will just work the first time. If it does not work the first time, you at least have a solid plan of what the code should be doing to guide your debugging.