1,105,286 Community Members

Time And Space Complexity

Member Avatar
nikilvarma
Newbie Poster
1 post since Jan 2007
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
Rashakil Fol
Super Senior Demiposter
2,596 posts since Jun 2005
Reputation Points: 982 [?]
Q&As Helped to Solve: 209 [?]
Skill Endorsements: 42 [?]
Team Colleague
 
1
 

I suppose somebody can.

Member Avatar
ssurajnayak
Newbie Poster
1 post since Sep 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
Anuradha Mandal
Junior Poster
122 posts since Sep 2010
Reputation Points: -28 [?]
Q&As Helped to Solve: 9 [?]
Skill Endorsements: 0 [?]
 
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

Member Avatar
apines
Practically a Master Poster
618 posts since Apr 2007
Reputation Points: 116 [?]
Q&As Helped to Solve: 56 [?]
Skill Endorsements: 0 [?]
Featured
 
0
 
Member Avatar
Dhruv Gairola
Junior Poster in Training
50 posts since Nov 2010
Reputation Points: -3 [?]
Q&As Helped to Solve: 7 [?]
Skill Endorsements: 0 [?]
 
0
 

what is your algorithm that you need help with?

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