1.11M Members

Time And Space Complexity

 
0
 

Hello
This is Nikil.Can anyone help me out how to calculate time and space complexity of an algorithm with examples.I am in very much need.Please help me out in detail.

 
1
 

I suppose somebody can.

 
0
 

TIME COMPLEXITY:Time compexity is(roughly speaking) how the algorithm behaves as the input increases. Something with time complexity O(n) will take twice the time when the input doubles, something with time complexity O(N^2) will take four times longer when the input duobles and so on.
SPACE COMPLEXITY:Space complexity is the storage required for the execution of the algorithm. This includes all permanent and temporary storage required by the algoritm, including any necessary stakc allocations for recursions.

 
0
 

Time complexity is a function which describes the amount of time an algorithm takes in terms of the amount of input to the algorithm.

Space complexity is a function which describes the amount of memory (space) an algorithm takes in terms of the amount of input to the algorithm.

EXAMPLE:

The complexity of linear search algorithm for avarage case
c(n)=1*1/n+2*1/n+3*1/n+.........+n*1/n
=(n+1)/2

 
0
 

what is your algorithm that you need help with?

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article