1. Introduction to data structures and their types.
2. Linear, non-linear, homogeneous, non-homogeneous, static and
dynamic data structures.
3. Linear data structures - array, stack, queue and linked list.
4. Non-linear data structures - tree and graph.
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Introduction to Data Structures .
1. Introduction to Data Structures
Dr. Ashutosh Satapathy
Assistant Professor, Department of CSE
VR Siddhartha Engineering College
Kanuru, Vijayawada
March 12, 2024
Dr. Ashutosh Satapathy Introduction to Data Structures March 12, 2024 1 / 30
2. Outline
1 Data Structures
Introduction
Classification
2 Types of Data Structures
Array
Linked List
Stack
Queue
Tree
Graph
3 Data Structure Operations
Dr. Ashutosh Satapathy Introduction to Data Structures March 12, 2024 2 / 30
3. Outline
1 Data Structures
Introduction
Classification
2 Types of Data Structures
Array
Linked List
Stack
Queue
Tree
Graph
3 Data Structure Operations
Dr. Ashutosh Satapathy Introduction to Data Structures March 12, 2024 3 / 30
4. Introduction
Computers can manipulate only primitive data, i.e., data in terms of
of 0’s and 1’s.
Manipulation of primitive data is inherent within the computer and
need not require any extra effort from the user’s side.
Various kinds of data, other than primitive data, are involved in
real-life applications.
Manipulation of real-life data, which can also be termed user-defined
data requires the following essential tasks:
1 Storage representation of user data: User data should be stored in
such a way that a computer can understand it.
2 Retrieval of stored data: Data stored on a computer should be
retrieved in such a way that the user can understand it.
3 Transformation of user data: Various operations that require
performed on user data so that it can be transformed from one form to
other.
Dr. Ashutosh Satapathy Introduction to Data Structures March 12, 2024 4 / 30
5. Introduction
Knowledge of data structures is required for people who design
and develop computer programs of any kind: system software or
application software.
Data are represented by values held temporarily within programs
and data areas or recorded permanently on a file.
Often, the different data values are related to each other. To enable
programs to make use of these relationships, these data values must
be in an organized form.
The organized collection of data is called a data structure. The
programs have to follow certain rules to access and process the
structured data.
Data Structures = Organized Data + Allowed Operations
Dr. Ashutosh Satapathy Introduction to Data Structures March 12, 2024 5 / 30
6. Introduction
Data may be organized in many different ways: the logical or
mathematical model of a particular organization of data is called a
data structure.
The choice of a particular data model depends on two considerations.
First, it must be rich enough in structure to mirror the actual
relationship of the data in the real world.
On the other hand, the structure should be simple enough that one
can effectively process the data when necessary.
Data structures may be classified as Arrays, lists, and files. These
are derived from the primitive data types (int, char, float, double).
These data structures emphasize the structuring of a group of
homogeneous (same type) or heterogeneous (different type) data
items.
Dr. Ashutosh Satapathy Introduction to Data Structures March 12, 2024 6 / 30
7. Outline
1 Data Structures
Introduction
Classification
2 Types of Data Structures
Array
Linked List
Stack
Queue
Tree
Graph
3 Data Structure Operations
Dr. Ashutosh Satapathy Introduction to Data Structures March 12, 2024 7 / 30
8. Data Structure Types
Figure 1.1: Classification of data structures
Dr. Ashutosh Satapathy Introduction to Data Structures March 12, 2024 8 / 30
9. Classification
Table 1.1: Types of Data Structures
Linear Non-Linear
In linear data structures, the data items
are arranged in a linear sequence like in
an array. Example: Array, Stack, Queue
and linked list
In non-linear data structures, the data
items are not in sequence.
Example: Tree, Graph and Trie
Homogeneous Non-Homogeneous
In a homogeneous data structure, all the
elements are the same type.
Example: Array
In a non-homogeneous data structure
the elements may or may not be the
same type. Example: Records
Static Dynamic
Static structures are ones whose sizes and
structures are associated with memory
locations fixed at compile time.
Example: Array
Dynamic structures expand or shrink
as required during program execution.
Example: Linked List
Dr. Ashutosh Satapathy Introduction to Data Structures March 12, 2024 9 / 30
10. Outline
1 Data Structures
Introduction
Classification
2 Types of Data Structures
Array
Linked List
Stack
Queue
Tree
Graph
3 Data Structure Operations
Dr. Ashutosh Satapathy Introduction to Data Structures March 12, 2024 10 / 30
11. Array
An array is defined as a set of finite number of homogeneous
elements or data items.
It means an array can contain one type of data only, either all
integers, all floating-point numbers, or all characters.
Declaration of arrays is as follows: int a[10], where int specifies the
data type or type of elements array stores.
a is the name of the array and the number specified inside the square
brackets is the number of elements an array can store; this is also
called size or length of the array.
The individual element of an array can be accessed by specifying the
array’s name, followed by index or subscript (an integer number
specifying the location of a clement in the array) inside square
brackets.
Dr. Ashutosh Satapathy Introduction to Data Structures March 12, 2024 11 / 30
12. Array
For example, to access the fifth element of array a, we have to give
the following statement: a[4];
The first element of the array has an index of zero (0). It means the
first and last elements will be specified as a[0] and a[9],
respectively.
The element of the array will always be stored in consecutive
memory locations.
The number of elements that can be stored in an array, i.e., the size
of an array or its length, is given by the following equation: (upper
bound - lower bound) + 1
For the above array, it would be (9 - 0) + 1 = 10, where 0 is the
lower bound and 9 is the upper bound.
Dr. Ashutosh Satapathy Introduction to Data Structures March 12, 2024 12 / 30
13. Array
Arrays can always be read or written through the loop.
Reading a one-dimensional array requires one loop for reading and
another for writing (printing) the array.
Reading a two-dimensional array requires two loops for reading
and two loops for writing (printing) the array.
Similarly, the array of n dimensions would require n loops.
Some common operations performed on arrays are:
1 Creation of an array.
2 Traversing an array (accessing array elements).
3 Insertion of new elements.
4 Deletion of the required element.
5 Modification of an element.
6 Merging of arrays.
Dr. Ashutosh Satapathy Introduction to Data Structures March 12, 2024 13 / 30
14. Outline
1 Data Structures
Introduction
Classification
2 Types of Data Structures
Array
Linked List
Stack
Queue
Tree
Graph
3 Data Structure Operations
Dr. Ashutosh Satapathy Introduction to Data Structures March 12, 2024 14 / 30
15. Linked List
A list (linear linked list) can be defined as a collection of a
variable number of data items. Linked lists are the most commonly
used data structures.
An element of a list must contain at least two fields, one for storing
data or information and the other for storing the address of the
next node.
For storing addresses, we have derived data types in C called pointers.
Hence, the second field of the list must be a pointer type.
Technically, each such element is referred to as a node. Therefore, a
list can be defined as a collection of nodes.
Figure 2.1: Single linked-list
Dr. Ashutosh Satapathy Introduction to Data Structures March 12, 2024 15 / 30
16. Outline
1 Data Structures
Introduction
Classification
2 Types of Data Structures
Array
Linked List
Stack
Queue
Tree
Graph
3 Data Structure Operations
Dr. Ashutosh Satapathy Introduction to Data Structures March 12, 2024 16 / 30
17. Stack
A stack is also an ordered collection of elements like arrays, but
it has a special feature that deletion and insertion of elements can be
done only from one end, called the top of the stack (TOP).
Due to this property, it is also called a last in, first out type of data
structure (LIFO).
It could be like a stack of plates placed on the table. A guest always
removes a fresh plate from the top, and the new plates are placed
onto the stack at the top.
Figure 2.2: Stack push operation
Dr. Ashutosh Satapathy Introduction to Data Structures March 12, 2024 17 / 30
18. Stack
Figure 2.3: Stack pop operation
When an element is inserted into or removed from a stack, its base
remains fixed, whereas the top of the stack changes.
Inserting an element into the stack is called Push, and deletion of
an element from the stack is called Pop.
Stacks can be implemented in two ways:
1 Using arrays (static implementation)
2 Using linked list (dynamic implementation)
Dr. Ashutosh Satapathy Introduction to Data Structures March 12, 2024 18 / 30
19. Outline
1 Data Structures
Introduction
Classification
2 Types of Data Structures
Array
Linked List
Stack
Queue
Tree
Graph
3 Data Structure Operations
Dr. Ashutosh Satapathy Introduction to Data Structures March 12, 2024 19 / 30
20. Queue
Queues 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 the rear end, and the elements are always removed from the
other end, called the front end.
The people standing in a railway reservation row are an example of a
queue. Each new person comes and stands at the end of the row (the
rear end of the queue), and people get their reservations confirmed.
Get out from the front end.
Queues can also be implemented in two ways:
1 Using arrays (static implementation)
2 Using linked list (dynamic implementation)
Figure 2.4: Simple queue
Dr. Ashutosh Satapathy Introduction to Data Structures March 12, 2024 20 / 30
21. Outline
1 Data Structures
Introduction
Classification
2 Types of Data Structures
Array
Linked List
Stack
Queue
Tree
Graph
3 Data Structure Operations
Dr. Ashutosh Satapathy Introduction to Data Structures March 12, 2024 21 / 30
22. Tree
A tree can be defined as finite set of data items (nodes).
Tree is a non-linear type of data structure in which data items are
arranged or stored in a sorted sequence.
Trees represent the hierarchical relationship between various
elements.
Here is a special data item at the top of the hierarchy called the
root of the tree.
The remaining data items are partitioned into several mutually
exclusive (i.e., disjoint) subsets, each of which is itself a tree,
which is called the sub-tree.
The tree always grows in length toward the bottom of the data
structures, unlike natural trees, which grow upwards.
Dr. Ashutosh Satapathy Introduction to Data Structures March 12, 2024 22 / 30
23. Tree
The tree structure organizes the data into branches, as shown in
the next figure. This type of structure is very useful in general.
Figure 2.5: Binary tree
Dr. Ashutosh Satapathy Introduction to Data Structures March 12, 2024 23 / 30
24. Outline
1 Data Structures
Introduction
Classification
2 Types of Data Structures
Array
Linked List
Stack
Queue
Tree
Graph
3 Data Structure Operations
Dr. Ashutosh Satapathy Introduction to Data Structures March 12, 2024 24 / 30
25. Graph
A graph is a mathematical non-linear data structure capable of
structures.
It represents many physical applications in geography, chemistry,
and engineering sciences.
A graph G(V , E) is a set of vertices v and edges e.
An edge connects a pair of vertices that may have weight, such as
length, cost, or another measuring instrument for recording a graph.
Vertices on the graph are shown as points or circles and edges as
arcs or line segments.
Thus, an edge can be represented as e = (v, w), where v and w are
pairs of vertices. The vertices v and w lie on e.
Vertices may be considered cities, and edges, arcs, and line
segments may be considered roads in a road network.
Dr. Ashutosh Satapathy Introduction to Data Structures March 12, 2024 25 / 30
26. Graph
(a) Directed graph (b) Undirected graph (c) Simple graph
(d) Connected graph (e) Non-connected graph (f) Multigraph
Figure 2.6: Types of graph
Dr. Ashutosh Satapathy Introduction to Data Structures March 12, 2024 26 / 30
27. Data Structure Operations
A large number of operations can be performed on data structures. Some
of the important operations are listed below.
1 Creating: A data structure is created.
2 Inserting: New items are added to the data structure.
3 Modifying: The values of a data structure are modified by replacing
old values.
4 Traversing: Each item in the data structure is visited for processing
purposes.
5 Searching: A data item is searched in the structure; the item may or
may not exist in the data structure.
Dr. Ashutosh Satapathy Introduction to Data Structures March 12, 2024 27 / 30
28. Data Structure Operations
6 Deleting: Deleting is a process of removing an item from the data
structure.
7 Sorting: Data items are sorted in ascending or descending order.
8 Merging: Data items in more than one sorted data structure are
merged together to produce a single sorted new data structure.
9 Copying: Data items from one structure are copied to another
structure.
10 Concatenating: Data items of a structure are appended at the end
of another type of structure.
11 Splitting: Data items in a very big structure are split into smaller
structures for processing.
Dr. Ashutosh Satapathy Introduction to Data Structures March 12, 2024 28 / 30
29. Summary
Here, we have discussed
Introduction to data structures and their types.
Linear, non-linear, homogeneous, non-homogeneous, static and
dynamic data structures.
Linear data structures - array, stack, queue and linked list.
Non-linear data structures - tree and graph.
Dr. Ashutosh Satapathy Introduction to Data Structures March 12, 2024 29 / 30
30. For Further Reading I
E. Horowitz, S. Sahni and S. A. Freed.
Fundamentals of Data Structures in C (2nd edition).
Universities Press, 2008.
A. K. Rath and A. K. Jagadev.
Data Structures Using C (2nd edition).
Scitech Publications, 2011.
M. A. Weiss
Data Structures and Algorithm Analysis in C (2nd edition).
Pearson India, 2022.
Dr. Ashutosh Satapathy Introduction to Data Structures March 12, 2024 30 / 30