Data Structures Unit-1 Chapter-1
Data Structures Unit-1 Chapter-1
Unit-1
Chapter-1
1.Introduction to Data Structures
1. Definition.
2. Classification of Data Structures.
3. Operations on Data Structures.
4. Abstract Data Types.
5. Preliminaries of Algorithms.
6. Time and Space Complexity.
1. Definition of Data Structures
There are two types of data structure available for the programming purpose:
• Primitive data structure
• Non-primitive data structure
Primitive data structure is a fundamental type of data structure that stores the
data of only one type whereas the non-primitive data structure is a type of data
structure which is a user-defined that stores the data of different types in a single
entity.
Classification of Data Structures
• Array: An array is a data structure that can hold the elements of same
type. It cannot contain the elements of different types like integer with
character. The commonly used operation in an array is insertion,
deletion, traversing, searching.
Example:
Linked List
• Linked List can be defined as collection of objects called nodes that are randomly
stored in the memory.
• A node contains two fields i.e. data stored at that particular address and the
pointer which contains the address of the next node in the memory.
• The last node of the list contains pointer to the null.
Root Node
Parent Node
Child Node
Sibling Node
Leaf Node
Binary Tree
The Binary tree means that the node can have maximum two children. Here, binary
name itself suggests that 'two'; therefore, each node can have either 0, 1 or 2 children.
Advantages:
Provides quick search, insert and delete operations.
• Graphs:-
A graph can be defined as group of vertices and edges, that are used to connect these vertices.
Directed and Undirected Graph:-
1. Time Complexity.
2. Space Complexity.
1. Time Complexity:-
• The time taken by an algorithm to complete its task.
• Eg:- Time taken to add an element first to an array and a linked list.
• The running time to perform any operation depends on the size of the
input. Eg:- Adding a 1st element to the array with a size of 100 takes less
time compared with adding 1st element to the array with the size of 1000.
2. Space Complexity:-
• Space Complexity can be defined as amount of memory (or) space required
by an Algorithm to run.
• To compute the space complexity we use 2 factors i. Constant ii. Instance
characteristics.
• The space requirement S(p) can be given as S(p) = C+Sp
where C- Constant, it denotes the space taken for input and output.
Sp – Amount of space taken by an instruction, variable and identifiers.