What is the difference between time complexity and space complexity?

Time and Space complexity are different aspects of calculating the efficiency of an algorithm.  

Time complexity deals with finding out how the computational time of an algorithm changes with the change in size of the input.  

On the other hand space complexity deals with finding out how much (extra)space would be required by the algorithm with change in the input size.  

To calculate time complexity of the algorithm the best way is to check if we increase in the size of the input, will the number of comparison(or computational steps) also increase and to calculate space complexity the best bet is to see additional memory requirement of the algorithm also changes with the change in the size of the input.

13-August 12:44 AM 2585 Views

 Prev question

Next question