First, we need to understand what is the algorithm?
An algorithm is just a procedure that takes some set of values as input and produces some set of values as output. In short, the procedure of solving a problem is an algorithm. We can say an algorithm is correct if it halts with the correct output for all inputs.
Now, What is the need for studying algorithms?
We know that our computers are not infinitely fast and do not have infinite storage. So we have to make our algorithms fast that uses less storage to efficiently use. Then maybe you have a question like, how we evaluate an algorithm? The answer is, we evaluate the efficiency of the algorithm by analyzing the bound of the time taken to execute its statements and produce output for all the given inputs, known as time complexity. We describe time complexity as the frequency of the statements that need to be executed. We can have multiple algorithms for the same problem, to choose an efficient one we need to study algorithms.
Basically, we write programs in any High-level Language like Python, C, C++, etc to solve problems. But do not care about their efficiency, an inefficient algorithm does not show any effect on less number of input but in million of inputs shows dramatic effects. I will show this by comparing two algorithms of sorting: Merge Sort and Insertion Sort.
This Shows us, Machine A is faster still takes more time as compared to machine B because merge sort is efficient as compare to Insertion sort for large inputs. That is the effect of an efficient algorithm. The system performance depends on the hardware as well as the algorithm we choose.
Top comments (0)