BASIC DIFFERENCES BETWEEN SPACE COMPLEXITY AND TIME COMPLEXITY

 

SPACE COMPLEXITY:

The space complexity of an algorithm is the amount of memory it requires to run to completion.

the space needed by a program contains the following components:

1)  Instruction space:

-stores the executable version of programs and is generally fixed.

2) Data space:

It contains:

a)  Space required by constants and simple variables.Its space is fixed.

b)  Space needed by fixed size stucture variables such as array and structures.

c)  dynamically allocated space.This space is usually variable.

3) enviorntal stack:

-Needed to stores information required to reinvoke suspended processes or functions.

the following data is saved on the stack

- return address.

-value of all local variables

-value of all formal parameters in the function..

TIME COMPLEXITY:

The time complexity of an algorithm is the amount of time it needs to run to completion. namely space

To measure the time complexity we can count all operations performed in an algorithm and if we know the time taken for each operation then we can easily compute the total time taken by the algorithm.This time varies from system to system.

Our intention is to estimate execution time of an algorithm irrespective of the computer on which it will be used. Hence identify the key operation and count such operation performed till the program completes its execution.

The time complexity can be expressd as a function of a key operation performed.

The space and time complexity is usually expressed in the form of function f(n),where n is the input size for a given instance of a problem being solved.

f(n) helps us to predict the rate of growthof complexity that will increase as size of input to the problem increases.

f(1) also helps us to predict complexity of two or more algorithms in order ro find which is more efficient.

 

Like it on Facebook, +1 on Google, Tweet it or share this article on other bookmarking websites.


Written by
deven rana
\"Live as if you were to die tomorrow. Learn as if you were to live forever.”
  • No comments found

Latest Articles

Well I don't think there's a better way to express your love for someone, than through songs. Cards, or the well planned 'unexpected gift at an unexpected
BUZZ SONGS (165 Hits)
If you're a Rock fan, you'll be aware that Rock music helps to raise your energy levels quickly. It creates a buzz, that re-energizes you. In this post
It all started off in Manchester, a band was formed by the Gallagher brothers. Liam & Noel Gallagher, started writing, & composing music, hoping

Related Articles

An army veteran has committed suicide and this has brought into focus the great divide that exists between reality and rhetoric. this was something bound
The Indian armed forces consist of the Army. Airforce and Navy. All 3 arms trace their pedigree to of the Raja.  They do not draw any sustenance  from
https://en.wikipedia.org/wiki/Lockheed_F-117_Nighthawk  When I visited the USA in 1998 as part of the air team we were quartered at one of the
India became free when British rule lapsed in 1947. It was freedom granted by the British and duly passed by an act of the British Parliament. It was not
The  Kashmir problem has been festering for 69 years with no solution in sight. One can trace the genesis of this problem to Pandit Jawaharlal Nehru.