Data Structure
Data Structure
(KCS301)
Unit - 1
• Essentials of C language
What is data Structure
• A data structure is a particular way of organizing
and storing data in a computer so that it can be
accessed and modified efficiently.
or
• A data structure is a collection of data values, the
relationships among them, and the functions or
operations that can be applied to the data.
Need of data Structure
Type of data structure
• According to nature of size
– Static data structure
– Dynamic data structure
• According to its occurrence
– Linear data structure
– Non-linear data structure
• Primitive and non-primitive
• Homogeneous and non-homogeneous
Type of data structure
• According to nature of size
– Static data structure
– Dynamic data structure
• According to its occurrence
– Linear data structure
– Non-linear data structure
• Primitive and non-primitive
• Homogeneous and non-homogeneous
Type of data structure
• According to nature of size
– Static data structure: A data structure said to be static if we can
store data up to a fix number. Eg: Array.
– Dynamic data structure
• According to its occurrence
– Linear data structure
– Non-linear data structure
• Primitive and non-primitive
• Homogeneous and non-homogeneous
Type of data structure
• According to nature of size
– Static data structure
– Dynamic data structure:
• According to its occurrence
– Linear data structure
– Non-linear data structure
• Primitive and non-primitive
• Homogeneous and non-homogeneous
Type of data structure
• According to nature of size
– Static data structure
– Dynamic data structure: which allows programmer to change its size during
program execution to add or delete data. E.g.. Link list, tree, graph etc.
• According to its occurrence
– Linear data structure
– Non-linear data structure
• Primitive and non-primitive
• Homogeneous and non-homogeneous
Type of data structure
• According to nature of size
– Static data structure
– Dynamic data structure
• According to its occurrence
– Linear data structure
– Non-linear data structure
• Primitive and non-primitive
• Homogeneous and non-homogeneous
Type of data structure
• According to nature of size
– Static data structure
– Dynamic data structure
• According to its occurrence
– Linear data structure: data stored in consecutive memory location or
in a sequential form. E.g. array, link list, queue, stack etc.
– Non-linear data structure
• Primitive and non-primitive
• Homogeneous and non-homogeneous
Type of data structure
• According to nature of size
– Static data structure
– Dynamic data structure
• According to its occurrence
– Linear data structure
– Non-linear data structure
• Primitive and non-primitive
• Homogeneous and non-homogeneous
Type of data structure
• According to nature of size
– Static data structure
– Dynamic data structure
• According to its occurrence
– Linear data structure
– Non-linear data structure: data stored in non consecutive memory
location or in inconsequential form. E.g. tree, graph etc.
• Primitive and non-primitive
• Homogeneous and non-homogeneous
Data Structure
Phisical Data
Logical Data Structure
Structure
3) Best Case
Type of Analysis
• We can have three cases to analyze an algorithm:
1) Worst Case
2) Average Case
3) Best Case Analysis (Bogus)
– In the best case analysis, we calculate lower bound on
running time of an algorithm. We must know the case
that causes minimum number of operations to be
executed.
Asymptotic Notations
data_type Array_name[size];
0 1 2 3 4
Base Address
A[2]
int A[5];
Type of Array
• 1 D Array
Eg: int A[5];
• 2 D Array
Eg: int A[5][4];
• 3 D Array
Eg: int A[5][4][2];
• n D Array
Eg: int A[5]………….[1];
Memmory allocation in 1D array
• Address of data element,
data_type array_name[row_size][column_size];
int marks[3][5];
Memory allocation
row major order
row major order
• The Location of element A[i, j] can be obtained by