SlideShare a Scribd company logo
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
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
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
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
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
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
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
Data Structure Types
Figure 1.1: Classification of data structures
Dr. Ashutosh Satapathy Introduction to Data Structures March 12, 2024 8 / 30
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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

More Related Content

PPTX
Breadth First Search & Depth First Search
PPTX
Trees in data structures
PDF
Trees, Binary Search Tree, AVL Tree in Data Structures
PPT
Data Structure and Algorithms Linked List
PDF
UNIT I LINEAR DATA STRUCTURES – LIST
PPTX
Presentation on Elementary data structures
PPTX
Doubly Linked List
PDF
Linked list implementation of Queue
Breadth First Search & Depth First Search
Trees in data structures
Trees, Binary Search Tree, AVL Tree in Data Structures
Data Structure and Algorithms Linked List
UNIT I LINEAR DATA STRUCTURES – LIST
Presentation on Elementary data structures
Doubly Linked List
Linked list implementation of Queue

What's hot (20)

PPTX
PPTX
Mid-Point Cirle Drawing Algorithm
PPTX
Stack and Queue by M.Gomathi Lecturer
PPTX
Stack and queue
PPT
Addressing
PPTX
Tree Traversal
PPTX
Linked List
PPT
data structure
PPT
Linked list
PPT
Heaps & priority queues
PPTX
Data structure and its types
PPTX
Trees data structure
PPTX
Introduction to data structures (ss)
PPT
Queue Data Structure
PPTX
Analysis of Algorithm - Binary Search.pptx
PPT
Binary search tree(bst)
PPTX
File in C language
PPTX
Hardwired control
PPTX
Doubly linked list (animated)
PPT
File handling in c
Mid-Point Cirle Drawing Algorithm
Stack and Queue by M.Gomathi Lecturer
Stack and queue
Addressing
Tree Traversal
Linked List
data structure
Linked list
Heaps & priority queues
Data structure and its types
Trees data structure
Introduction to data structures (ss)
Queue Data Structure
Analysis of Algorithm - Binary Search.pptx
Binary search tree(bst)
File in C language
Hardwired control
Doubly linked list (animated)
File handling in c
Ad

Similar to Introduction to Data Structures . (20)

PPT
Unit 1.ppt
PPT
DS_PPT.ppt
PPT
DATA STRUCTURES A BRIEF OVERVIEW OF DATA
PPTX
DS_PPT.pptx
PPT
data structure algorithm example and example
PPT
1597380885789.ppt
PPT
Lecture 1 - Overview of Data Structure .ppt
PPT
Fundamentals of data structure syallabus
PPT
Data structure study material introduction
PPT
DATA STRUCTURE AND ALGORITJM POWERPOINT.ppt
PPTX
dsa.pptx
PPTX
Lecture 2 Data Structure Introduction
PPT
DS_INTROduction dhjm,asjkfnsflkwefskdmcsdmckds
PPT
PM.ppt DATA STRUCTURE USING C WITH EXAMPLE PROGRAMES
PPT
DS.ppt Datatastructures notes presentation
PDF
Data structure
PPTX
Lecture 1.pptxffffffffffffffcfffffffffff
PDF
3130703dsgtudarshan Enotesallunits Darshan Institute Of Engineering Technology
PDF
slidesgo-mastering-data-structures-and-algorithms-the-backbone-of-efficient-p...
PDF
slidesgo-mastering-data-structures-and-algorithms-the-backbone-of-efficient-p...
Unit 1.ppt
DS_PPT.ppt
DATA STRUCTURES A BRIEF OVERVIEW OF DATA
DS_PPT.pptx
data structure algorithm example and example
1597380885789.ppt
Lecture 1 - Overview of Data Structure .ppt
Fundamentals of data structure syallabus
Data structure study material introduction
DATA STRUCTURE AND ALGORITJM POWERPOINT.ppt
dsa.pptx
Lecture 2 Data Structure Introduction
DS_INTROduction dhjm,asjkfnsflkwefskdmcsdmckds
PM.ppt DATA STRUCTURE USING C WITH EXAMPLE PROGRAMES
DS.ppt Datatastructures notes presentation
Data structure
Lecture 1.pptxffffffffffffffcfffffffffff
3130703dsgtudarshan Enotesallunits Darshan Institute Of Engineering Technology
slidesgo-mastering-data-structures-and-algorithms-the-backbone-of-efficient-p...
slidesgo-mastering-data-structures-and-algorithms-the-backbone-of-efficient-p...
Ad

More from Ashutosh Satapathy (12)

PDF
Visual Aids for Exploratory Data Analysis.pdf
PDF
20ES1152 Programming for Problem Solving Lab Manual VRSEC.pdf
PDF
Linked List Data Structures .
PDF
The Value of Business Intelligence .
PDF
Business Intelligence and Information Exploitation.pdf
PDF
Searching and Sorting Algorithms
PDF
Multidimensional Data
PDF
Time and Space Complexity
PDF
Algorithm Specification and Data Abstraction
PDF
Secure Multi-Party Computation
Visual Aids for Exploratory Data Analysis.pdf
20ES1152 Programming for Problem Solving Lab Manual VRSEC.pdf
Linked List Data Structures .
The Value of Business Intelligence .
Business Intelligence and Information Exploitation.pdf
Searching and Sorting Algorithms
Multidimensional Data
Time and Space Complexity
Algorithm Specification and Data Abstraction
Secure Multi-Party Computation

Recently uploaded (20)

PDF
Digital Logic Computer Design lecture notes
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPT
Mechanical Engineering MATERIALS Selection
PDF
composite construction of structures.pdf
PPTX
Sustainable Sites - Green Building Construction
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
web development for engineering and engineering
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
Construction Project Organization Group 2.pptx
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
DOCX
573137875-Attendance-Management-System-original
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPT
Project quality management in manufacturing
Digital Logic Computer Design lecture notes
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
Mechanical Engineering MATERIALS Selection
composite construction of structures.pdf
Sustainable Sites - Green Building Construction
bas. eng. economics group 4 presentation 1.pptx
Foundation to blockchain - A guide to Blockchain Tech
Embodied AI: Ushering in the Next Era of Intelligent Systems
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
web development for engineering and engineering
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Construction Project Organization Group 2.pptx
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
UNIT-1 - COAL BASED THERMAL POWER PLANTS
573137875-Attendance-Management-System-original
Operating System & Kernel Study Guide-1 - converted.pdf
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Project quality management in manufacturing

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