Written by deven rana. Posted in Computer Science on 09 August 2011.
Hot 5085 hits 0 favoured

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.

 


deven rana

Author: deven rana

17 8345 4
\"Live as if you were to die tomorrow. Learn as if you were to live forever.”
  • No comments found
Powered by CjBlog

Latest Articles

In this article, we will cover other provisions that have attained a degree of notoriety in recent times for their effect on suppressing online freedom
Not there yet! (15 Hits)
Well, I have shifted to Hyderabad and it is almost six months. This is my second visit to Hyderabad. I am not new to this place as I did my masters from
You might have seen many people (especially male youngsters) with bloated and swollen face.  Most of the time people think its because of drinking

Categories

Related Articles

The ancient Hindu granths outline a path to god through sex. This is the essence of tantra sex that forms an important part of Hindu philosophy.  But
Recently on a visit to the USA I read an article that some American wives of Civil war veterans were still drawing pension.  This surprised me as
Believed to have been written between 400 B.C and 200 A.D by Vyatsyayana, Kama Sutra is a manual, intended to help the people to lead a healthy sex
Mutual attraction at work places Mutual attraction between men and women is a fact of life. Whenever men and women work together, sexual attraction comes
Sex is in your mind Most people think sex as a physical feeling, an enjoyment that on feels through his organs but it’s not so. Organs are only medium