1) Introduction To Data Structures
1) Introduction To Data Structures
1) Introduction To Data Structures
PRASANTA MANGAR
DEPT OF CSA
ST. JOSEPH’S COLLEGE
DARJEELING
DEFINITION
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
STRUCTURE
Data structure
Primitive DS Non-Primitive DS
Non-Primitive DS
Linear Data Structure: Data structure where data elements are arranged sequentially or linearly where each
and every element is attached to its previous and next adjacent is called a linear data structure. In linear
data structure, single level is involved.
Non-linear Data Structure: Data structures where data elements are not arranged sequentially or linearly are
called non-linear data structures. In a non-linear data structure, single level is not involved.
NON-PRIMITIVE DATA STRUCTURE
Lists, Stack, Queue, Tree, Graph are example of non-
primitive data structures.
The design of an efficient data structure must take
operations to be performed on the data structure.
NON-PRIMITIVE DATA STRUCTURE
PUSH POP
[STACK]
STACK
The stack can be implemented into two ways:
Using arrays (Static implementation)
Using pointer (Dynamic
implementation)
QUEUE
Queue are first in first out type of data structure (i.e. FIFO)
In a queue new elements are added to the queue from one end
called REAR end and the element are always removed from
other end called the FRONT end.
The people standing in a railway reservation row are an
example of queue.
QUEUE
Each new person comes and stands at the end of the row
and person getting their reservation confirmed get out of
the row from the front end.
The bellow show figure how the operations take place on
a stack:
10 20 30 40 50
front rear
QUEUE
The queue can be implemented into two ways:
Using arrays (Static implementation)
Using pointer (Dynamic
implementation)
TREES
A tree can be defined as finite set of data items (nodes).
Tree is non-linear type of data structure in which data
items are arranged or stored in a sorted sequence.
Tree represent the hierarchical relationship between
various elements.
TREES
In trees:
There is a special data item at the top of hierarchy called the
Root of the tree.
The remaining data items are partitioned into number of
mutually exclusive subset, each of which is itself, a tree
which is called the sub tree.
The tree always grows in length towards bottom in data
structures, unlike natural trees which grows upwards.
TREES
The tree structure organizes the data into branches,
which related the information.
A root
B C
D E F G
GRAPH
Graph is a mathematical non-linear data structure
capable of representing many kind of physical structures.
It has found application in Geography, Chemistry and
Engineering sciences.
Definition: A graph G(V,E) is a set of vertices V and a set
of edges E.
GRAPH
An edge connects a pair of vertices and many have
weight such as length, cost and another measuring
instrument for according the graph.
Vertices on the graph are shown as point or circles and
edges are drawn as arcs or line segment.
GRAPH
Example of graph:
6
v2 v5
v1 v3
10
v1 8 11
15
9 v2
v3 v4 v4