0% found this document useful (0 votes)
24 views9 pages

Complexity

Uploaded by

akashsoni1379
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views9 pages

Complexity

Uploaded by

akashsoni1379
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

SPACE COMPLEXITY

&
TIME COMPLEXITY

1
ALGORITHMS
COMPLEXITY

2
WHAT IS AN ALGORITHM??

Analgorithm is a step-by-
step procedure for solving a
problem in a finite amount of
time.

3
ANALYSIS OF
ALGORITHMS OR
PERFORMANCE ANALYSIS

 Program performance is the amount of


computer memory and time needed to
run a program.

4
CRITERIA FOR MEASUREMENT

Two criteria are used to judge algorithms:


(i)time complexity
(ii)space complexity.

Space Complexity of an algorithm is the


amount of memory it needs to run to
completion.

Time Complexity of an algorithm is the


amount of CPU time it needs to run to
completion. 5
SPACE COMPLEXITY
 Memoryspace S(P) needed by a
program P, consists of two
components:

A fixed part: needed for instruction


space (byte code), simple variable
space, constants space etc.  c

A variable part: dependent on a


particular instance of input and
output data.  Sp(instance)
6

 S(P) = c + Sp(instance)
TIME COMPLEXITY
 Timerequired T(P) to run a
program P also consists of two
components:

A fixed part: compile time which


is independent of the problem
instance  c.

A variable part: run time which


7
depends on the problem
instance  t (instance)
conclusion
 The recursive function has lower step
count then its iterative counterpart.
 Recursive function typically run slower

than the iterative version & takes more


time than those of the iterative function.
 Recursive function also uses more

memory space for its each call.


 For space complexity, iterative function

is better than recursive function.


 For time complexity , recursive function

is better than iterative function. 8


THANK YOU !!!

You might also like