DS Lec01
DS Lec01
Definition
Data structure
Primitive DS Non-Primitive DS
Non-Primitive DS
PUSH POP
[STACK]
Stack
• The stack can be implemented into two ways:
– Using arrays (Static implementation)
– Using pointer (Dynamic implementation)
Queue
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