An algorithm is a sequence of steps to solve a problem; there may be more than
one algorithm to solve a problem. The choice of a particular algorithm depends upon following consideration:-
1) Time Complexity
2) Space Complexity
Time Complexity:- The time complexity of an algorithm is the amount of time it needs to run to completion. Some of the reasons for studying time complexity are:-
We may be interested to know in advance whether the program will provide a satisfactory real time response.
There may be several possible solutions with different time requirement.
Space Complexity:- The space complexity of an algorithm is the amount of memory it needs to run to completion. Some of the reasons to study space complexity are: -
There may be several possible solutions with in different space requirement.
To estimate the size of the largest problem that a program can solve.