Unit1 - Introduction - To - Data - Structures
Unit1 - Introduction - To - Data - Structures
Unit I
Introduction to Data
structures
By
Mrs. Dhanashree Nalinde
Lecturer in Computer Engineering
Government Polytechnic Nagpur
What is Data?
• Data:- data can be defined as a representation of facts,
concepts or instructions in a formalized manner suitable for
communication, interpretation or processing by human or
electronic machine.
Neha 23 II year 89
Definition
• Data Structure is a way of collecting and organizing data in
such a way that we can perform operations on these data in an
effective way.
2. Efficiency:-
• The main reason we organize the data is to improve the
efficiency.
• So the fact that we are interested in other data structures is
because of the efficiency.
Why we need data structures?
1. Data structure helps us to store & organize data in a
logical or mathematical manner.
2. Data structure helps us to analyze the data in a logical or
mathematical manner.
3. Data structure helps to solve complex and large
problems for handling large amount of data.
4. Data structure helps us to understand the relationship of
one data element with the other.
Basic Operations
The data in the data structures are processed by certain operations. The
particular data structure chosen largely depends on the frequency of
the operation that needs to be performed on the data structure.
(Upperbound-lowerbound)+1
Arrays
• For the above array it would be
(9-0)+1=10,where 0 is the lower bound of array and 9
is the upper bound of array.
1 Tanmay
D.M.Shirkey
2 H
3 E
4 A
5 B
6 C
.
Lists
• Technically each such element is referred to as a node,
therefore a list can be defined as a collection of nodes as show
bellow:
PUSH POP
[STACK]
Basic features of Stack
• Stack is an ordered list of similar data type.
• Stack is a LIFO(Last in First out) structure or we can
say FILO(First in Last out).
• push() function is used to insert new elements into the
Stack and pop() function is used to remove an element from
the stack. Both insertion and removal are allowed at only
one end of Stack called Top.
• Stack is said to be in Overflow state when it is completely
full and is said to be in Underflow state if it is completely
empty.
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
Some real life examples of Queue
Operations on Queue
• Queue operations may involve initializing or defining the queue,
utilizing it, and then completely erasing it from the memory. Here
we shall try to understand the basic operations associated with
queues −
• enqueue() − add (store) an item to the queue.
• dequeue() − remove (access) an item from the queue.
Basic features of Queue
• 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.
Graphs
Graph
• Example of graph:
6
v2 v5
v1 v3
10
v1 8 11
15
9 v2
v3 v4 v4
Types of Graphs:
• Directed graph
• Undirected graph
• Simple graph
• Weighted graph
• Connected graph
• Non-connected graph