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.

6
Contributors
5
Replies
9
Views
11 Years
Discussion Span
Last Post by Dhruv Gairola

I suppose somebody can.

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.

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

what is your algorithm that you need help with?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.