Home / Questions / What is the algorithm?
Explanatory Question

What is the algorithm?

👁 1,032 Views
📘 Detailed Answer
🕒 Easy to Read
Read the answer carefully and go through the related questions on the right side to improve your understanding of this topic.

Answer with Explanation

Let us consider the problem of preparing an omelet. To prepare an omelet, we follow the
steps given below:

1) Get the frying pan.
2) Get the oil.
   a. Do we have oil?
       i. If yes, put it in the pan.
       ii. If no, do we want to buy oil?
           1. If yes, then go out and buy.
           2. If no, we can terminate.
3) Turn on the stove, etc...


What we are doing is, for a given problem (preparing an omelet), we are providing a step-by-step procedure for solving it. The formal definition of an algorithm can be stated as:
An algorithm is the step-by-step unambiguous instructions to solve a given problem. In the traditional study of algorithms, there are two main criteria for judging the merits of algorithms: correctness (does the algorithm give a solution to the problem in a finite number of steps?) and efficiency (how much resources (in terms of memory and time) does it take to execute them).

Note: We do not have to prove each step of the algorithm.