0% found this document useful (0 votes)
8 views

Time and Space complexity

Uploaded by

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

Time and Space complexity

Uploaded by

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

Data Structures

(Lecture 05 and 06)

Prof. P. T. Sawant
Asst. Prof.
Department of Computer Science & Information
Technology
Agenda
 Review

 Time and Space Complexity

 Efficiency

 Assignment
TIME AND SPACE COMPLEXITY
• Complexity of algorithm is a function of size of input of a
given problem instance which determines how much running
time/memory space is needed by the algorithm in order to
run to completion.
1. Time Complexity: Time complexity of an algorithm is the
amount of time it needs in order to run to completion.
2. Space Complexity: Space Complexity of an algorithm is the
amount of space it needs in order to run to completion.
There are two points which we should consider about computer
programming:-
(i) An appropriate data structure and
(ii) An appropriate algorithm.
Growth of functions
• Algorithms have a primary parameter N that affects the
running time most significantly
– N typically represents the size of the input– e.g., file size, no. of
chars in a string; etc.
• Commonly encounterd running times are proportional to
the following functions
– 1 :Represents a constant
– Log N :Logarithmic
– N :Linear time
– N log N :Linearithmic(?)
– N2 :Quadratic
– N3 :Cubic
– 2N :Exponential
Some common functions

lg N N 0.5 N N lg N N (lg N ) 2 N2 2N

3 3 10 33 110 100 1042

7 10 100 664 444 10000 210x10= 104210

10 32 1000 9966 99317 1000000 ?

13 100 10000 132877 1765633 100000000 ?

17 316 100000 1660964 27588016 10000000000 ?

20 1000 1000000 19931569 397267426 1000000000000 ?


TIME COMPLEXITY

Time Complexity: Time complexity of an algorithm is the


amount of time it needs in order to run to completion.
Algorithm
Algorithm
Example
Example
Example
Example
Example
Thank You

You might also like