SlideShare a Scribd company logo
1 of 30
Download to read offline
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

Similar to Introduction to Data Structures .

datastructure-201021140600.pptx
datastructure-201021140600.pptxdatastructure-201021140600.pptx
datastructure-201021140600.pptxZISAN5
 
DATA STRUCTURES - SHORT NOTES
DATA STRUCTURES - SHORT NOTESDATA STRUCTURES - SHORT NOTES
DATA STRUCTURES - SHORT NOTESsuthi
 
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada ReddyDatastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada ReddyMalikireddy Bramhananda Reddy
 
ARRAYS IN C++ CBSE AND STATE +2 COMPUTER SCIENCE
ARRAYS IN C++ CBSE AND STATE +2 COMPUTER SCIENCEARRAYS IN C++ CBSE AND STATE +2 COMPUTER SCIENCE
ARRAYS IN C++ CBSE AND STATE +2 COMPUTER SCIENCEVenugopalavarma Raja
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptxSaralaT3
 
chapter three ppt.pptx
chapter three ppt.pptxchapter three ppt.pptx
chapter three ppt.pptxselemonGamo
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptxsarala9
 
data structure details of types and .ppt
data structure details of types and .pptdata structure details of types and .ppt
data structure details of types and .pptpoonamsngr
 
module-1.pdf. Uooyuf sh kcgfkgkggfjk
module-1.pdf.         Uooyuf sh kcgfkgkggfjkmodule-1.pdf.         Uooyuf sh kcgfkgkggfjk
module-1.pdf. Uooyuf sh kcgfkgkggfjkanil23hr1a0547
 
Data structures introduction
Data structures   introductionData structures   introduction
Data structures introductionmaamir farooq
 
data structure programing language in c.ppt
data structure programing language in c.pptdata structure programing language in c.ppt
data structure programing language in c.pptLavkushGupta12
 
DATA STRUCTURE
DATA STRUCTUREDATA STRUCTURE
DATA STRUCTURERohit Rai
 
8074.pdf
8074.pdf8074.pdf
8074.pdfBAna36
 
Datastructures using c++
Datastructures using c++Datastructures using c++
Datastructures using c++Gopi Nath
 
2nd puc computer science chapter 3 data structures 1
2nd puc computer science chapter 3 data structures 12nd puc computer science chapter 3 data structures 1
2nd puc computer science chapter 3 data structures 1Aahwini Esware gowda
 

Similar to Introduction to Data Structures . (20)

datastructure-201021140600.pptx
datastructure-201021140600.pptxdatastructure-201021140600.pptx
datastructure-201021140600.pptx
 
DATA STRUCTURES - SHORT NOTES
DATA STRUCTURES - SHORT NOTESDATA STRUCTURES - SHORT NOTES
DATA STRUCTURES - SHORT NOTES
 
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada ReddyDatastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
 
ARRAYS IN C++ CBSE AND STATE +2 COMPUTER SCIENCE
ARRAYS IN C++ CBSE AND STATE +2 COMPUTER SCIENCEARRAYS IN C++ CBSE AND STATE +2 COMPUTER SCIENCE
ARRAYS IN C++ CBSE AND STATE +2 COMPUTER SCIENCE
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptx
 
Ch1
Ch1Ch1
Ch1
 
Datastructures Notes
Datastructures NotesDatastructures Notes
Datastructures Notes
 
chapter three ppt.pptx
chapter three ppt.pptxchapter three ppt.pptx
chapter three ppt.pptx
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptx
 
data structure details of types and .ppt
data structure details of types and .pptdata structure details of types and .ppt
data structure details of types and .ppt
 
module-1.pdf. Uooyuf sh kcgfkgkggfjk
module-1.pdf.         Uooyuf sh kcgfkgkggfjkmodule-1.pdf.         Uooyuf sh kcgfkgkggfjk
module-1.pdf. Uooyuf sh kcgfkgkggfjk
 
Data structures introduction
Data structures   introductionData structures   introduction
Data structures introduction
 
data structure programing language in c.ppt
data structure programing language in c.pptdata structure programing language in c.ppt
data structure programing language in c.ppt
 
DATA STRUCTURE
DATA STRUCTUREDATA STRUCTURE
DATA STRUCTURE
 
8074.pdf
8074.pdf8074.pdf
8074.pdf
 
Datastructures using c++
Datastructures using c++Datastructures using c++
Datastructures using c++
 
Struktur data ppt
Struktur data pptStruktur data ppt
Struktur data ppt
 
2nd puc computer science chapter 3 data structures 1
2nd puc computer science chapter 3 data structures 12nd puc computer science chapter 3 data structures 1
2nd puc computer science chapter 3 data structures 1
 
data structure
data structuredata structure
data structure
 
104333 sri vidhya eng notes
104333 sri vidhya eng notes104333 sri vidhya eng notes
104333 sri vidhya eng notes
 

More from Ashutosh Satapathy

More from Ashutosh Satapathy (7)

Searching and Sorting Algorithms
Searching and Sorting AlgorithmsSearching and Sorting Algorithms
Searching and Sorting Algorithms
 
Multidimensional Data
Multidimensional DataMultidimensional Data
Multidimensional Data
 
Time and Space Complexity
Time and Space ComplexityTime and Space Complexity
Time and Space Complexity
 
Algorithm Specification and Data Abstraction
Algorithm Specification and Data Abstraction Algorithm Specification and Data Abstraction
Algorithm Specification and Data Abstraction
 
ORAM
ORAMORAM
ORAM
 
ObliVM
ObliVMObliVM
ObliVM
 
Secure Multi-Party Computation
Secure Multi-Party ComputationSecure Multi-Party Computation
Secure Multi-Party Computation
 

Recently uploaded

Basic Electronics for diploma students as per technical education Kerala Syll...
Basic Electronics for diploma students as per technical education Kerala Syll...Basic Electronics for diploma students as per technical education Kerala Syll...
Basic Electronics for diploma students as per technical education Kerala Syll...ppkakm
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaOmar Fathy
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxSCMS School of Architecture
 
Electromagnetic relays used for power system .pptx
Electromagnetic relays used for power system .pptxElectromagnetic relays used for power system .pptx
Electromagnetic relays used for power system .pptxNANDHAKUMARA10
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptDineshKumar4165
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationBhangaleSonal
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdfAldoGarca30
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesMayuraD1
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network DevicesChandrakantDivate1
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXssuser89054b
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayEpec Engineered Technologies
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Arindam Chakraborty, Ph.D., P.E. (CA, TX)
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptxJIT KUMAR GUPTA
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...drmkjayanthikannan
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startQuintin Balsdon
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdfKamal Acharya
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueBhangaleSonal
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdfKamal Acharya
 
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptxOrlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptxMuhammadAsimMuhammad6
 

Recently uploaded (20)

Basic Electronics for diploma students as per technical education Kerala Syll...
Basic Electronics for diploma students as per technical education Kerala Syll...Basic Electronics for diploma students as per technical education Kerala Syll...
Basic Electronics for diploma students as per technical education Kerala Syll...
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
Electromagnetic relays used for power system .pptx
Electromagnetic relays used for power system .pptxElectromagnetic relays used for power system .pptx
Electromagnetic relays used for power system .pptx
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network Devices
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptxOrlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
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