What is an Algorithm?

In an informal way: It is a procedure or set of procedures, working in such a way that you need to specify what are you trying to achieve step-by-step. You will need to be explaining like you are telling a story to a 5 year old :)

In formal way: Well-defined computational procedure which expectes a value / set of values as input. Then, produces a result using those input. It needs to be sequential. An algorithm acts as a tool and helps us solve a problem in computer science. It is like a blueprint that describes computational procedure in order to achieve desired input/output.

Basic informal example: Let’s say you want to go grocery shopping and decided to buy some eggs to bake a cake. Of course your brain works in mysterious ways and perform this task automatically, but have you ever wondered how? Indeed it knows the algorithm required to buy eggs. It follows those steps:

1) Wear something suitable for the occassion. 2) If you are not sure how many eggs you need, then check recipe book. 3) Decide how many eggs you are going to get, head out. 4) Enter the market/store. 5) Find dairy products section, fetch those eggs. 6) Pay for them and return home.

As you can see, we have effortlessly managed to type in some algorithm. An algorithm does not have to be specified in sentences. It can be specified as a computer program, or graphical representation even a hardware design.

PS: In order to an algorithm be correct, for every input it should give the correct output. Pro Tip: An incorrect algorithm might come in handy too, if their error rate can be controlled.