Lect01 102 2019
Lect01 102 2019
Data Structures
CSN- 102
Dr. R. Balasubramanian
Professor
Department of Computer Science and Engineering
Indian Institute of Technology Roorkee
Roorkee 247 667
balarfcs@iitr.ac.in
https://sites.google.com/site/balaiitr/
CSN 102
• Syllabus
2
Why This Course?
3
• Algorithm:
– A set of explicit, unambiguous finite steps, which when carried out
for a given set of initial condition to produce the corresponding
output and terminate in finite time.
• Program:
– An implementation of an algorithm in some programming languages
• Data Structure:
– Organization of data needed to solve the problem
4
Good Algo.’?
• Efficient
– Running Time
– Space Used
• Running time depends on
– Single vs Multi processor
– Read or Write speed to Memory
– 32 bit vs 64 bit
– Input -> rate of growth of time, Efficiency as a function of input
(number of bits in an input number, number of data elements…)
5
• Time Complexity: Amount of computation time (CPU time)
where program needs to run
6
Measuring the Running Time
7
Limitations
8
How to Analyze Time Complexity?
9
Few Examples
TAdd=1+1=2 units of
time
= Constant time
10
Sum of all elements in the list
=cn+c’
• Tsum_of_Matrices =a*n^2+b*n+c
TAdd =O(1)
TSum_of_list = O(n)
Tsum_of_Matrices =O(n2)
Asymptotic Notation
12