Chap-1_Introduction-to-Data-Structure
Chap-1_Introduction-to-Data-Structure
Structure
CONTENTS
1.1 Basic Terminology
1. Elementary data structure organization
2. Classification of data structure
1.2 Operations on data structures
1.3 Different Approaches to designing an algorithm
1. Top-Down approach
2. Bottom-up approach
1.4 Complexity
1. Time complexity
2. Space complexity
1.5 Big ‘O’ Notation
Hours: 6
Marks: 8
1. Introduction to Data Structure
Figure 1.1
Anuradha Bhatia 2
1. Introduction to Data Structure
Anuradha Bhatia 3
1. Introduction to Data Structure
1.4 Complexity
1. Time complexity
(Question: Explain time complexity of an algorithm with operation
count and step count- 4 Marks)
Time Complexity is divided in to THREE Types.
i. Best Case Time Complexity: Efficiency of an algorithm for an input of size
N for which the algorithm takes the smallest amount of time.
ii. Average Case Time Complexity: It gives the expected value of T(n).
Average case is used when worst case and best case doesn’t gives any
necessary information about algorithm’s behavior, then the algorithm’s
efficiency is calculated on Random input.
iii. Worst Case Time Complexity: efficiency of an algorithm for an input of size
N for which the algorithm takes the longest amount of time.
Figure 1.2
Anuradha Bhatia 4
1. Introduction to Data Structure
Example
Figure 1.3
Anuradha Bhatia 5
1. Introduction to Data Structure
Figure 1.4
iv. In the above program there are no instance characteristics and the space
needed by x, y, z and sum is independent of instance characteristics. The
space for each integer variable is 2. We have 4 integer variables and space
needed by x, y, z and sum are 4 * 2 = 8 bytes.
S (p) = Cp + Sp
S (p) = 8 + 0
S (p) = 8
Anuradha Bhatia 6
1. Introduction to Data Structure
Figure 1.5
Figure 1.6
Anuradha Bhatia 7
1. Introduction to Data Structure
Figure 1.7
Anuradha Bhatia 8