954,498 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Time And Space Complexity

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.

nikilvarma
Newbie Poster
1 post since Jan 2007
Reputation Points: 10
Solved Threads: 0
 

I suppose somebody can.

Rashakil Fol
Super Senior Demiposter
Team Colleague
2,658 posts since Jun 2005
Reputation Points: 1,135
Solved Threads: 177
 

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.

ssurajnayak
Newbie Poster
1 post since Sep 2010
Reputation Points: 10
Solved Threads: 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

Anuradha Mandal
Junior Poster
122 posts since Sep 2010
Reputation Points: 0
Solved Threads: 10
 
apines
Practically a Master Poster
633 posts since Apr 2007
Reputation Points: 129
Solved Threads: 55
 

what is your algorithm that you need help with?

Dhruv Gairola
Junior Poster in Training
50 posts since Nov 2010
Reputation Points: 7
Solved Threads: 7
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You