SlideShare a Scribd company logo
A
Presentation
on
Introduction to Data Structures
Presented by:
Ms. Bulbul Agrawal
Assistant Professor
Email Id: bulbulag04@gmail.com
Contents
Course Objective
Introduction
Classification of Data Structures
Description of various types of Data Structures
Course Outcomes
Recommended Books and Virtual Labs
Course Objectives
To be familiar with the use of data structures as the foundational
base for computer solutions to problem.
To understand various techniques of searching and sorting.
To understand basic concepts about array, stack, queue, list, trees
and graphs.
Why?
Computer system is used as Data Management System where ‘Data’
are very important for it.
Data are aggregated and summarized in various ways to form
information.
All these factors very much depend on the way data are aggregated.
The data structures are an effective and reliable way to achieve this.
Why?
It is important for every Computer Science student to understand the
concept of Information and how it is organized or how it can be
utilized.
What is Information?
If we arrange some data in an appropriate sequence, then it forms a
structure and gives us a meaning. This meaning is called
Information. The basic unit of Information in Computer Science is a
bit, Binary Digit .
So, we found two things in Information: One is Data and the other is
Structure .
What is Data Structures?
Data structure means organizing the data in the memory.
Data structure is a particular way of organizing or structuring data
while storing in a computer so that it can be used effectively.
Data structure is representation of the logical relationship existing
between individual elements of data.
In other words, a data structure is a way of organizing all data items
that considers not only the elements stored but also their relationship
to each other.
What is Data Structures?
A data structure is a systematic way of organizing and accessing
data.
A data structure tries to structure data!
• Usually more than one piece of data
• Should define legal operations on the data
• The data might be grouped together
When we define a data structure we are in fact creating a new data
type of our own.
What is Data Structures?
Data structure affects the design of both structural & functional
aspects of a program.
Program=algorithm + Data Structure
That means, algorithm is a set of instruction written to carry out
certain tasks & the data structure is the way of organizing the data
with their logical relationship retained.
To develop a program of an algorithm, we should select an
appropriate data structure for that algorithm.
Data Structure mainly specifies the following
four things:
Organization of data (Amount of memory requires to store)
Accessing methods(Amount of time requires to process)
Degree of associativity (How the data items are related to each
other)
Processing alternatives for information
Need of Data Structures
As applications are getting complexed and amount of data is increasing day by day,
there may arise the following problems:
Processor speed: To handle very large amount of data, high speed processing is
required, but as the data is growing day by day to the billions of files per entity,
processor may fail to deal with that much amount of data.
Data Search: Consider an inventory size of 106 items in a store, If our
application needs to search for a particular item, it needs to traverse 106 items
every time, results in slowing down the search process.
Multiple requests: If thousands of users are searching the data simultaneously
on a web server, then there are the chances that a very large server can be failed
during that process. In order to solve the above problems, data structures are
used.
Data is organized to form a data structure in such a way that all items are not
required to be searched and required data can be searched instantly.
Classification of Data Structures
Primitive Data Structures
Primitive data structure is a fundamental type of data structure that
stores the data of only one type.
It contains fundamental data types such as integer, float, character,
pointer, and these fundamental data types can hold a single type of
value. For example, integer variable can hold integer type of value.
There are basic structures and directly operated upon by the machine
instructions.
Non-Primitive Data Structures
The non-primitive data structures emphasize on structuring of a
group of homogeneous or heterogeneous data items.
The design of an efficient data structure must take operations to be
performed on the data structure.
Non-primitive data types are not defines by the programming
language, but are instead created by the programmer.
They are sometimes called “Reference variables” or “Object
References”, Since they reference a memory location, which stores
the data.
Non-Primitive Data Structure
The most commonly used operation on data structure are broadly
categorized into following types:
Create
Selection
Updating
Searching
Sorting
Merging
Destroy or Delete
Non-Primitive Data Structures
In the case of non-primitive data structure, it is categorized into two
parts.
Linear data structure is a sequential type of data structure, and here
sequential means that all the elements in the memory are stored in a
sequential manner; for example, element stored after the second
element would be the third element, and so on. We have different
linear data structures holding the sequential values such as Array,
Linked list, Stack, Queue.
Non-linear data structure is a kind of random type of data structure.
The non-linear data structures are Tree and Graph.
DESCRIPTION OF VARIOUS DATA
STRUCTURES
Array
An array is defined as a set of finite number of homogeneous
elements or same data items.
It means an array can contain one type of data only, either all
integer, all float-point number or all character.
Declaration of array is a s follows:
Syntax: Datatype Array_Name[Size];
Example: int arr[10];
Where int specifies the data type or type of elements arrays stores.
“arr” is the name of array & the number specified inside the square
brackets is the number of elements an array can store, this is called
sized or length of array.
Array
Represent a array in memory:
• The elements of array are stored in consecutive memory locations.
• It is shown below:
int A[6]={23, 4, 6, 15, 5, 7}
Array
Calculating the length of the array:
• The elements of array will always be stored in the consecutive
(continues) memory location.
• The number of elements that can be stored in an array, i.e. the size of
array or its length is given by the following equation:
Length=UB-LB+1
• For example: if any array A has values 10,20,30,40,50 stored in
location 0,1,2,3,4 then UB=4 and LB=0
• Size of the array Length=4-0+1=5
Array: Types of Array
Single Dimension Array:
Array with one subscript
Example: int A[i];
Two Dimension Array:
Array with two subscript (Rows and Columns)
Example: int A[i][j];
Multi Dimension Array:
Array with Multiple subscripts
Example: int A[i][j][k]…..[n];
Array
Array can always be read or written through loop. If we read a one-
dimensional array it require one loop for reading and other for
writing the array.
For example: Reading and writing an array
For(int i=0;i<=9;i++)
scanf(“%d”,&arr[i]);
For(int i=0;i<=9;i++)
printf(“%d”,arr[i]);
If we are reading or writing two-dimensional array it would require
two loops. And similarly the array of a N-dimension would required
N loops.
Array
Some common operation performed on array are:
• Traversing
• Insertion
• Deletion
• Searching
• Sorting
Array: Traversing an Array
It is used to access each data item exactly once so that it can be
processed.
We have an array A as;
Here we will start from beginning and will go till last element and
during this process we will access value of each element exactly once
as below;
Array: Insertion into Array
It is used to add a new data item in the given collection of data
items. We have an array arr as: [10,20,30,40], n=4, pos=2, value=25
Array: Deleting from Array
It is used to delete an existing data item from the given collection of
data items. Arr=[10,20,30,40,50], n=5, pos=2 (Index to delete)
Array: Searching
It is used to find out the location of the data item if it exists in the
given collection of data items;
E.g. we have linear array A as below:
Suppose item to be searched is 35. We will start form beginning and
will compare 35 with each element.
This process will continue until element is found or array is finished.
Types of searching algorithms:
1. Linear Search
2. Binary Search
Array: Sorting
A sorting algorithm is used to rearrange a given array or list
elements.
Types of sorting algorithms are:
• Bubble sort
• Insertion sort
• Selection sort
• Merge sort
• Quick sort
• Heap sort
Array: 2D Array
A 2D array is a collection of elements and each element is identified
by a pair of subscript A[3][3]
The number of rows and columns in a matrix is called as the order of
the matrix (or total number of obtained elements) and denoted as
M*N.
We need M*N memory locations to store
M*N number of elements.
There are two methods:
1. Row-major order and 2. Column-major order
Array: Representation of 2D Array
Row-Major Order: All the first row elements are stored in
sequential memory locations and then all the second-row elements
are stored and so on. Ex: A[Row][Col]
Column-Major Order: All the first column elements are stored in
sequential memory locations and then all the second-column
elements are stored and so on. Ex: A[Col][Row]
Stack
Stack is a linear data structure which follows a particular order in
which the operations are performed.
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)
Insertion of element into stack is called PUSH and deletion of
element from stack is called POP. The order may be LIFO or FILO.
Stack
It could be through of just like a stack of plates placed on table in a
party, a guest always takes off a fresh plate from the top and the new
plates are placed on to the stack at the top.
When an element is inserted into a stack or removed from the stack,
its base remains fixed where the top of stack changes.
Stack
The various operation performed on stacks depends on the following
conditions:
Stack: PUSH Operation
The process of adding one element or item to the stack is
represented by an operation called as the PUSH operation.
Stack: POP Operation
The process of deleting one element from the stack is represented by
an operation called as the POP operation. When elements are
removed continuously from a stack, it shrinks at same end i.e., top:
Stack: Operations on Stack
The various operation performed on stacks are:
• Stack(): It creates a new stack that is empty. It needs no parameter
and returns an empty stack.
• Push(item): It adds a new item to the top of the stack.
• Pop(): It removes the top item from the stack.
• Peek(): It returns the top item from the stack but does not remove it.
• isEmpty(): It tests whether the stack is empty.
• Size(): It returns the number of items on the stack.
Queue
A queue is an ordered collection of items where an item is inserted at
one end called the “rear” and an existing item is removed at the other
end, called the “front”.
Queue is also called as FIFO list.
In the queue only two operations are allowed enqueue and dequeue.
Enqueue means to insert an item into back of the queue and dequeue
means removing the front item.
Queue: Memory Representation of Queue
The condition FRONT=NULL indicates that queue is empty.
The condition REAR=N-1 indicates that queue is full.
Queue: Types of Queue
Simple Queue: In a simple queue insertion occurs at the rear end of
the list and deletion occurs at the front end of the list.
Circular Queue: A circular queue is a queue in which all nodes are
treated as circular such that the last node follows the first node.
Queue: Types of Queue
Priority Queue: A priority queue is a queue that contains items that
have some present priority. An element can be inserted or removed
from any position depending upon some priority.
Double Ended Queue: It is a queue in which insertion and deletion
takes place at the both ends.
Queue: Enqueue Operation
Queue: Dequeue Operation
Linked List
A linked list can be defined as a collection of variable number of
data items called nodes.
Each node is divided into two parts:
1. The first part contains the information of the element.
2. The second part contains the memory address of the next node in
the list. Also called link part.
Linked List: Types of Linked List
Singly Linked List
Doubly Linked List
Circular Linked List
Linked List: Singly Linked List
A singly linked list contains two fields in each node- an information
field and the linked field.
• The information field contains the data of that node.
• The link field contains the memory address of the next node.
• The last link field contains the memory address as null (/).
• There is only one link field in each node, the linked list is called
singly linked list.
Linked List: Doubly Linked List
It is a linked list in which each node is points both to the next node
and also to the previous node.
In doubly linked list each node contains three parts:
1. Next: It is a pointer field that contains the address of the next node.
2. Prev: It is a pointer field that contains the address of the previous
node.
3. Data: It contains the actual data.
Linked List: Doubly Linked List
In the first node, if prev contains NULL, it indicates that it is the
first node in the list.
If next contains NULL, it indicates that the node is the last node.
Linked List: Circular Linked List
The link field of the last node contains the memory address of the
first node, such a linked list is called circular linked list.
• The information field contains the data of that node.
• The link field contains the memory address of the next node.
• The last link field contains the memory address of the first node.
• In a circular linked list every node is accessible from a given node.
Linked List: Operations on Linked List
The operation that are performed on linked lists are:
• Creating a linked list
• Traversing a linked list
• Inserting an item into a linked list (Beginning, End, Specific Place)
• Deleting an item from the linked list (Beginning, End, Specific
Place)
• Searching an item in the linked list
Non-Linear Data Structures
A non-linear data structures is a data structure in which data item is
connected to several other data items:
• The data items in non-linear data structure represent hierarchical
relationship.
• Each data item is called node.
• The different non-linear data structure are:
Trees
Graphs
Tree
A tree is a data structure consisting of nodes organized as a
hierarchy.
Tree is a hierarchical data structures which stores the information
naturally in the form of hierarchy style.
It represents the nodes connected by edges.
Tree: Terminologies of a Tree
Graph
Graph is a mathematical non-linear data structure capable of
representing many kind of physical structures.
• A graph is a collection of nodes called vertices and the connection
between them called edges.
Definition: A graph G(V,E) is a set of vertices V and a set of edges
E.
Graph: Types of Graph
• Directed Graph
• Undirected Graph
• Simple Graph
• Weighted Graph
• Connected Graph
• Non-Connected Graph
Applications of various data structures
Array:
• An array can be used for CPU
scheduling.
• Book pages are also real-life
examples of an array.
• The array is used in many
management systems like a library,
students, parliament, etc.
Stack:
• Browsers use stack data structures to
keep track of previously visited sites.
• Call log in mobile also uses stack
data structure.
• The stack is used in the media
players. Useful to play the next and
previous song.
Queue:
• Queues are used for job scheduling
in the operating system.
• To send an e-mail queue data
structure is used.
• It helps in serving requests on a
single shared resource, like a printer,
CPU task scheduling, etc.
Linked List:
• It helps in memory management.
• Linked lists are used to display
image containers. Users can visit
past, current, and next images.
• They are used to store the history of
the visited page.
Trees:
• Spanning trees are used in routers in
computer networks.
• Domain Name Server also uses a
tree data structure.
Graphs:
• The operating system uses Resource
Allocation Graph.
• Google Maps where cities are
located as vertices and paths
connecting those vertices are located
as edges of the graph.
• A social network where every person
on the network is a node, and all of
their friendships on the network are
the edges of the graph.
Course Outcomes
After completion of this course, the students would be able to:
CO1: Outline the basics of algorithms and their performance criteria.
CO2: Explain the working of linear/non-linear data structures.
CO3: Identify the appropriate data structure to solve specific
problems.
CO4: Analyse the performance of various data structures & their
applications.
CO5: Evaluate the time/space complexities of various data structures
& their applications.
CO6: Design the optimal algorithmic solution for various problems.
Recommended Books
Data Structures, Algorithm and Applications in C++, Sartaj Sahni.
An introduction to Data Structures with Applications, Jean-Paul
Tremblay, Mcgraw hill.
Data Structures & Algorithms, Aho, Hopcroft &Ullman, Original
edition, Pearson Publication.
Virtual Labs of Data Structures
https://www.vlab.co.in/broad-area-computer-science-and-
engineering
Introduction to Data Structures and their importance
Introduction to Data Structures and their importance

More Related Content

What's hot (20)

PPTX
Data Structures in Python
Devashish Kumar
 
PPTX
XML DTD DOCUMENT TYPE DEFINITION
SaraswathiRamalingam
 
PPT
Sql select
Mudasir Syed
 
PPTX
Data structure & its types
Rameesha Sadaqat
 
PPTX
Introduction to Data Structures & Algorithms
Afaq Mansoor Khan
 
PPT
Entity relationship modelling
Dr. C.V. Suresh Babu
 
PPTX
Type of database models
SanthiNivas
 
PPTX
Array ppt
Kaushal Mehta
 
PPTX
B and B+ tree
Ashish Arun
 
PPTX
Xml namespace
GayathriS578276
 
PPTX
Binary Heap Tree, Data Structure
Anand Ingle
 
PPSX
Data Structure (Queue)
Adam Mukharil Bachtiar
 
PPTX
Stacks IN DATA STRUCTURES
Sowmya Jyothi
 
PPT
SEARCHING AND SORTING ALGORITHMS
Gokul Hari
 
PPTX
stack & queue
manju rani
 
PPT
Data structure
Muhammad Farhan
 
PPT
Multi catch statement
myrajendra
 
PPTX
Relational model
Dabbal Singh Mahara
 
PPT
Data structures using c
Prof. Dr. K. Adisesha
 
PPTX
Application of Data structure
Deepika051991
 
Data Structures in Python
Devashish Kumar
 
XML DTD DOCUMENT TYPE DEFINITION
SaraswathiRamalingam
 
Sql select
Mudasir Syed
 
Data structure & its types
Rameesha Sadaqat
 
Introduction to Data Structures & Algorithms
Afaq Mansoor Khan
 
Entity relationship modelling
Dr. C.V. Suresh Babu
 
Type of database models
SanthiNivas
 
Array ppt
Kaushal Mehta
 
B and B+ tree
Ashish Arun
 
Xml namespace
GayathriS578276
 
Binary Heap Tree, Data Structure
Anand Ingle
 
Data Structure (Queue)
Adam Mukharil Bachtiar
 
Stacks IN DATA STRUCTURES
Sowmya Jyothi
 
SEARCHING AND SORTING ALGORITHMS
Gokul Hari
 
stack & queue
manju rani
 
Data structure
Muhammad Farhan
 
Multi catch statement
myrajendra
 
Relational model
Dabbal Singh Mahara
 
Data structures using c
Prof. Dr. K. Adisesha
 
Application of Data structure
Deepika051991
 

Similar to Introduction to Data Structures and their importance (20)

PPTX
Introduction to Data Structure
chouguleamruta24
 
PPTX
DataStructurePpt-01.pptxEngineering data structure notes
limev72215
 
PPTX
Unit-1 DataStructure Intro.pptx
ajajkhan16
 
PPTX
ntroduction of Algorithms, Analysing Algorithms. Arrays: Sparse Matrices - Re...
kalaip3
 
PPTX
DataStructureccvdgddfffdesddsssdssPpt.pptx
bgmi52926
 
PDF
Data Structure Ppt for our engineering college industrial training.
AnumaiAshish
 
PPTX
DataStructurePpt.pptx
DCABCA
 
PPTX
Lecture 1.pptxffffffffffffffcfffffffffff
andrewandjames
 
PPTX
Introduction to data structures (ss)
Madishetty Prathibha
 
PPTX
DataStructurePpt.pptx
ssuser031f35
 
PPTX
DATA STRUCTURE AND COMPUTER ALGORITHMS LECTURE 1
emathemathematics
 
PPT
Unit 1.ppt
Minakshee Patil
 
PPT
CS301-lec01.ppt
omair31
 
PPTX
1-Introduction to Data Structures beginner.pptx
231b209
 
PPT
C++ Data Structure PPT.ppt
Mukesh Thakur
 
PPTX
datastructure concepts ppt-190327174340.pptx
JeevaMCSEKIOT
 
PPT
Data structures cs301 power point slides lecture 01
shaziabibi5
 
PPT
Data Structure Lec #1
University of Gujrat, Pakistan
 
PDF
Data structure using c++
Prof. Dr. K. Adisesha
 
PPTX
C++ Data Structure PPT.pptx
Mukesh Thakur
 
Introduction to Data Structure
chouguleamruta24
 
DataStructurePpt-01.pptxEngineering data structure notes
limev72215
 
Unit-1 DataStructure Intro.pptx
ajajkhan16
 
ntroduction of Algorithms, Analysing Algorithms. Arrays: Sparse Matrices - Re...
kalaip3
 
DataStructureccvdgddfffdesddsssdssPpt.pptx
bgmi52926
 
Data Structure Ppt for our engineering college industrial training.
AnumaiAshish
 
DataStructurePpt.pptx
DCABCA
 
Lecture 1.pptxffffffffffffffcfffffffffff
andrewandjames
 
Introduction to data structures (ss)
Madishetty Prathibha
 
DataStructurePpt.pptx
ssuser031f35
 
DATA STRUCTURE AND COMPUTER ALGORITHMS LECTURE 1
emathemathematics
 
Unit 1.ppt
Minakshee Patil
 
CS301-lec01.ppt
omair31
 
1-Introduction to Data Structures beginner.pptx
231b209
 
C++ Data Structure PPT.ppt
Mukesh Thakur
 
datastructure concepts ppt-190327174340.pptx
JeevaMCSEKIOT
 
Data structures cs301 power point slides lecture 01
shaziabibi5
 
Data Structure Lec #1
University of Gujrat, Pakistan
 
Data structure using c++
Prof. Dr. K. Adisesha
 
C++ Data Structure PPT.pptx
Mukesh Thakur
 
Ad

More from Bulbul Agrawal (7)

PPTX
Software Metrics, Project Management and Estimation
Bulbul Agrawal
 
PPTX
Analysis and Design of Algorithms
Bulbul Agrawal
 
PPTX
Age Estimation And Gender Prediction Using Convolutional Neural Network.pptx
Bulbul Agrawal
 
PPTX
Techniques for creating an effective resume
Bulbul Agrawal
 
PPTX
Standard Statistical Feature analysis of Image Features for Facial Images usi...
Bulbul Agrawal
 
PPT
Image segmentation
Bulbul Agrawal
 
PPTX
Image enhancement techniques
Bulbul Agrawal
 
Software Metrics, Project Management and Estimation
Bulbul Agrawal
 
Analysis and Design of Algorithms
Bulbul Agrawal
 
Age Estimation And Gender Prediction Using Convolutional Neural Network.pptx
Bulbul Agrawal
 
Techniques for creating an effective resume
Bulbul Agrawal
 
Standard Statistical Feature analysis of Image Features for Facial Images usi...
Bulbul Agrawal
 
Image segmentation
Bulbul Agrawal
 
Image enhancement techniques
Bulbul Agrawal
 
Ad

Recently uploaded (20)

PPTX
Introduction to Design of Machine Elements
PradeepKumarS27
 
PPTX
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
PPTX
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
PDF
Electrical Engineer operation Supervisor
ssaruntatapower143
 
PPTX
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
PDF
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
PPTX
Big Data and Data Science hype .pptx
SUNEEL37
 
PPTX
Evaluation and thermal analysis of shell and tube heat exchanger as per requi...
shahveer210504
 
PPTX
MATLAB : Introduction , Features , Display Windows, Syntax, Operators, Graph...
Amity University, Patna
 
PDF
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
PDF
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
PPTX
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
DOCX
8th International Conference on Electrical Engineering (ELEN 2025)
elelijjournal653
 
PPTX
Presentation 2.pptx AI-powered home security systems Secure-by-design IoT fr...
SoundaryaBC2
 
PPTX
Product Development & DevelopmentLecture02.pptx
zeeshanwazir2
 
PPTX
Element 11. ELECTRICITY safety and hazards
merrandomohandas
 
PPTX
Heart Bleed Bug - A case study (Course: Cryptography and Network Security)
Adri Jovin
 
PPTX
Introduction to Basic Renewable Energy.pptx
examcoordinatormesu
 
DOCX
CS-802 (A) BDH Lab manual IPS Academy Indore
thegodhimself05
 
PDF
Introduction to Productivity and Quality
মোঃ ফুরকান উদ্দিন জুয়েল
 
Introduction to Design of Machine Elements
PradeepKumarS27
 
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
Electrical Engineer operation Supervisor
ssaruntatapower143
 
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
Big Data and Data Science hype .pptx
SUNEEL37
 
Evaluation and thermal analysis of shell and tube heat exchanger as per requi...
shahveer210504
 
MATLAB : Introduction , Features , Display Windows, Syntax, Operators, Graph...
Amity University, Patna
 
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
8th International Conference on Electrical Engineering (ELEN 2025)
elelijjournal653
 
Presentation 2.pptx AI-powered home security systems Secure-by-design IoT fr...
SoundaryaBC2
 
Product Development & DevelopmentLecture02.pptx
zeeshanwazir2
 
Element 11. ELECTRICITY safety and hazards
merrandomohandas
 
Heart Bleed Bug - A case study (Course: Cryptography and Network Security)
Adri Jovin
 
Introduction to Basic Renewable Energy.pptx
examcoordinatormesu
 
CS-802 (A) BDH Lab manual IPS Academy Indore
thegodhimself05
 
Introduction to Productivity and Quality
মোঃ ফুরকান উদ্দিন জুয়েল
 

Introduction to Data Structures and their importance

  • 1. A Presentation on Introduction to Data Structures Presented by: Ms. Bulbul Agrawal Assistant Professor Email Id: [email protected]
  • 2. Contents Course Objective Introduction Classification of Data Structures Description of various types of Data Structures Course Outcomes Recommended Books and Virtual Labs
  • 3. Course Objectives To be familiar with the use of data structures as the foundational base for computer solutions to problem. To understand various techniques of searching and sorting. To understand basic concepts about array, stack, queue, list, trees and graphs.
  • 4. Why? Computer system is used as Data Management System where ‘Data’ are very important for it. Data are aggregated and summarized in various ways to form information. All these factors very much depend on the way data are aggregated. The data structures are an effective and reliable way to achieve this.
  • 5. Why? It is important for every Computer Science student to understand the concept of Information and how it is organized or how it can be utilized. What is Information? If we arrange some data in an appropriate sequence, then it forms a structure and gives us a meaning. This meaning is called Information. The basic unit of Information in Computer Science is a bit, Binary Digit . So, we found two things in Information: One is Data and the other is Structure .
  • 6. What is Data Structures? Data structure means organizing the data in the memory. Data structure is a particular way of organizing or structuring data while storing in a computer so that it can be used effectively. Data structure is representation of the logical relationship existing between individual elements of data. In other words, a data structure is a way of organizing all data items that considers not only the elements stored but also their relationship to each other.
  • 7. What is Data Structures? A data structure is a systematic way of organizing and accessing data. A data structure tries to structure data! • Usually more than one piece of data • Should define legal operations on the data • The data might be grouped together When we define a data structure we are in fact creating a new data type of our own.
  • 8. What is Data Structures? Data structure affects the design of both structural & functional aspects of a program. Program=algorithm + Data Structure That means, algorithm is a set of instruction written to carry out certain tasks & the data structure is the way of organizing the data with their logical relationship retained. To develop a program of an algorithm, we should select an appropriate data structure for that algorithm.
  • 9. Data Structure mainly specifies the following four things: Organization of data (Amount of memory requires to store) Accessing methods(Amount of time requires to process) Degree of associativity (How the data items are related to each other) Processing alternatives for information
  • 10. Need of Data Structures As applications are getting complexed and amount of data is increasing day by day, there may arise the following problems: Processor speed: To handle very large amount of data, high speed processing is required, but as the data is growing day by day to the billions of files per entity, processor may fail to deal with that much amount of data. Data Search: Consider an inventory size of 106 items in a store, If our application needs to search for a particular item, it needs to traverse 106 items every time, results in slowing down the search process. Multiple requests: If thousands of users are searching the data simultaneously on a web server, then there are the chances that a very large server can be failed during that process. In order to solve the above problems, data structures are used. Data is organized to form a data structure in such a way that all items are not required to be searched and required data can be searched instantly.
  • 12. Primitive Data Structures Primitive data structure is a fundamental type of data structure that stores the data of only one type. It contains fundamental data types such as integer, float, character, pointer, and these fundamental data types can hold a single type of value. For example, integer variable can hold integer type of value. There are basic structures and directly operated upon by the machine instructions.
  • 13. Non-Primitive Data Structures The non-primitive data structures emphasize on structuring of a group of homogeneous or heterogeneous data items. The design of an efficient data structure must take operations to be performed on the data structure. Non-primitive data types are not defines by the programming language, but are instead created by the programmer. They are sometimes called “Reference variables” or “Object References”, Since they reference a memory location, which stores the data.
  • 14. Non-Primitive Data Structure The most commonly used operation on data structure are broadly categorized into following types: Create Selection Updating Searching Sorting Merging Destroy or Delete
  • 15. Non-Primitive Data Structures In the case of non-primitive data structure, it is categorized into two parts. Linear data structure is a sequential type of data structure, and here sequential means that all the elements in the memory are stored in a sequential manner; for example, element stored after the second element would be the third element, and so on. We have different linear data structures holding the sequential values such as Array, Linked list, Stack, Queue. Non-linear data structure is a kind of random type of data structure. The non-linear data structures are Tree and Graph.
  • 16. DESCRIPTION OF VARIOUS DATA STRUCTURES
  • 17. Array An array is defined as a set of finite number of homogeneous elements or same data items. It means an array can contain one type of data only, either all integer, all float-point number or all character. Declaration of array is a s follows: Syntax: Datatype Array_Name[Size]; Example: int arr[10]; Where int specifies the data type or type of elements arrays stores. “arr” is the name of array & the number specified inside the square brackets is the number of elements an array can store, this is called sized or length of array.
  • 18. Array Represent a array in memory: • The elements of array are stored in consecutive memory locations. • It is shown below: int A[6]={23, 4, 6, 15, 5, 7}
  • 19. Array Calculating the length of the array: • The elements of array will always be stored in the consecutive (continues) memory location. • The number of elements that can be stored in an array, i.e. the size of array or its length is given by the following equation: Length=UB-LB+1 • For example: if any array A has values 10,20,30,40,50 stored in location 0,1,2,3,4 then UB=4 and LB=0 • Size of the array Length=4-0+1=5
  • 20. Array: Types of Array Single Dimension Array: Array with one subscript Example: int A[i]; Two Dimension Array: Array with two subscript (Rows and Columns) Example: int A[i][j]; Multi Dimension Array: Array with Multiple subscripts Example: int A[i][j][k]…..[n];
  • 21. Array Array can always be read or written through loop. If we read a one- dimensional array it require one loop for reading and other for writing the array. For example: Reading and writing an array For(int i=0;i<=9;i++) scanf(“%d”,&arr[i]); For(int i=0;i<=9;i++) printf(“%d”,arr[i]); If we are reading or writing two-dimensional array it would require two loops. And similarly the array of a N-dimension would required N loops.
  • 22. Array Some common operation performed on array are: • Traversing • Insertion • Deletion • Searching • Sorting
  • 23. Array: Traversing an Array It is used to access each data item exactly once so that it can be processed. We have an array A as; Here we will start from beginning and will go till last element and during this process we will access value of each element exactly once as below;
  • 24. Array: Insertion into Array It is used to add a new data item in the given collection of data items. We have an array arr as: [10,20,30,40], n=4, pos=2, value=25
  • 25. Array: Deleting from Array It is used to delete an existing data item from the given collection of data items. Arr=[10,20,30,40,50], n=5, pos=2 (Index to delete)
  • 26. Array: Searching It is used to find out the location of the data item if it exists in the given collection of data items; E.g. we have linear array A as below: Suppose item to be searched is 35. We will start form beginning and will compare 35 with each element. This process will continue until element is found or array is finished. Types of searching algorithms: 1. Linear Search 2. Binary Search
  • 27. Array: Sorting A sorting algorithm is used to rearrange a given array or list elements. Types of sorting algorithms are: • Bubble sort • Insertion sort • Selection sort • Merge sort • Quick sort • Heap sort
  • 28. Array: 2D Array A 2D array is a collection of elements and each element is identified by a pair of subscript A[3][3] The number of rows and columns in a matrix is called as the order of the matrix (or total number of obtained elements) and denoted as M*N. We need M*N memory locations to store M*N number of elements. There are two methods: 1. Row-major order and 2. Column-major order
  • 29. Array: Representation of 2D Array Row-Major Order: All the first row elements are stored in sequential memory locations and then all the second-row elements are stored and so on. Ex: A[Row][Col] Column-Major Order: All the first column elements are stored in sequential memory locations and then all the second-column elements are stored and so on. Ex: A[Col][Row]
  • 30. Stack Stack is a linear data structure which follows a particular order in which the operations are performed. 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) Insertion of element into stack is called PUSH and deletion of element from stack is called POP. The order may be LIFO or FILO.
  • 31. Stack It could be through of just like a stack of plates placed on table in a party, a guest always takes off a fresh plate from the top and the new plates are placed on to the stack at the top. When an element is inserted into a stack or removed from the stack, its base remains fixed where the top of stack changes.
  • 32. Stack The various operation performed on stacks depends on the following conditions:
  • 33. Stack: PUSH Operation The process of adding one element or item to the stack is represented by an operation called as the PUSH operation.
  • 34. Stack: POP Operation The process of deleting one element from the stack is represented by an operation called as the POP operation. When elements are removed continuously from a stack, it shrinks at same end i.e., top:
  • 35. Stack: Operations on Stack The various operation performed on stacks are: • Stack(): It creates a new stack that is empty. It needs no parameter and returns an empty stack. • Push(item): It adds a new item to the top of the stack. • Pop(): It removes the top item from the stack. • Peek(): It returns the top item from the stack but does not remove it. • isEmpty(): It tests whether the stack is empty. • Size(): It returns the number of items on the stack.
  • 36. Queue A queue is an ordered collection of items where an item is inserted at one end called the “rear” and an existing item is removed at the other end, called the “front”. Queue is also called as FIFO list. In the queue only two operations are allowed enqueue and dequeue. Enqueue means to insert an item into back of the queue and dequeue means removing the front item.
  • 37. Queue: Memory Representation of Queue The condition FRONT=NULL indicates that queue is empty. The condition REAR=N-1 indicates that queue is full.
  • 38. Queue: Types of Queue Simple Queue: In a simple queue insertion occurs at the rear end of the list and deletion occurs at the front end of the list. Circular Queue: A circular queue is a queue in which all nodes are treated as circular such that the last node follows the first node.
  • 39. Queue: Types of Queue Priority Queue: A priority queue is a queue that contains items that have some present priority. An element can be inserted or removed from any position depending upon some priority. Double Ended Queue: It is a queue in which insertion and deletion takes place at the both ends.
  • 42. Linked List A linked list can be defined as a collection of variable number of data items called nodes. Each node is divided into two parts: 1. The first part contains the information of the element. 2. The second part contains the memory address of the next node in the list. Also called link part.
  • 43. Linked List: Types of Linked List Singly Linked List Doubly Linked List Circular Linked List
  • 44. Linked List: Singly Linked List A singly linked list contains two fields in each node- an information field and the linked field. • The information field contains the data of that node. • The link field contains the memory address of the next node. • The last link field contains the memory address as null (/). • There is only one link field in each node, the linked list is called singly linked list.
  • 45. Linked List: Doubly Linked List It is a linked list in which each node is points both to the next node and also to the previous node. In doubly linked list each node contains three parts: 1. Next: It is a pointer field that contains the address of the next node. 2. Prev: It is a pointer field that contains the address of the previous node. 3. Data: It contains the actual data.
  • 46. Linked List: Doubly Linked List In the first node, if prev contains NULL, it indicates that it is the first node in the list. If next contains NULL, it indicates that the node is the last node.
  • 47. Linked List: Circular Linked List The link field of the last node contains the memory address of the first node, such a linked list is called circular linked list. • The information field contains the data of that node. • The link field contains the memory address of the next node. • The last link field contains the memory address of the first node. • In a circular linked list every node is accessible from a given node.
  • 48. Linked List: Operations on Linked List The operation that are performed on linked lists are: • Creating a linked list • Traversing a linked list • Inserting an item into a linked list (Beginning, End, Specific Place) • Deleting an item from the linked list (Beginning, End, Specific Place) • Searching an item in the linked list
  • 49. Non-Linear Data Structures A non-linear data structures is a data structure in which data item is connected to several other data items: • The data items in non-linear data structure represent hierarchical relationship. • Each data item is called node. • The different non-linear data structure are: Trees Graphs
  • 50. Tree A tree is a data structure consisting of nodes organized as a hierarchy. Tree is a hierarchical data structures which stores the information naturally in the form of hierarchy style. It represents the nodes connected by edges.
  • 52. Graph Graph is a mathematical non-linear data structure capable of representing many kind of physical structures. • A graph is a collection of nodes called vertices and the connection between them called edges. Definition: A graph G(V,E) is a set of vertices V and a set of edges E.
  • 53. Graph: Types of Graph • Directed Graph • Undirected Graph • Simple Graph • Weighted Graph • Connected Graph • Non-Connected Graph
  • 54. Applications of various data structures Array: • An array can be used for CPU scheduling. • Book pages are also real-life examples of an array. • The array is used in many management systems like a library, students, parliament, etc. Stack: • Browsers use stack data structures to keep track of previously visited sites. • Call log in mobile also uses stack data structure. • The stack is used in the media players. Useful to play the next and previous song. Queue: • Queues are used for job scheduling in the operating system. • To send an e-mail queue data structure is used. • It helps in serving requests on a single shared resource, like a printer, CPU task scheduling, etc. Linked List: • It helps in memory management. • Linked lists are used to display image containers. Users can visit past, current, and next images. • They are used to store the history of the visited page. Trees: • Spanning trees are used in routers in computer networks. • Domain Name Server also uses a tree data structure. Graphs: • The operating system uses Resource Allocation Graph. • Google Maps where cities are located as vertices and paths connecting those vertices are located as edges of the graph. • A social network where every person on the network is a node, and all of their friendships on the network are the edges of the graph.
  • 55. Course Outcomes After completion of this course, the students would be able to: CO1: Outline the basics of algorithms and their performance criteria. CO2: Explain the working of linear/non-linear data structures. CO3: Identify the appropriate data structure to solve specific problems. CO4: Analyse the performance of various data structures & their applications. CO5: Evaluate the time/space complexities of various data structures & their applications. CO6: Design the optimal algorithmic solution for various problems.
  • 56. Recommended Books Data Structures, Algorithm and Applications in C++, Sartaj Sahni. An introduction to Data Structures with Applications, Jean-Paul Tremblay, Mcgraw hill. Data Structures & Algorithms, Aho, Hopcroft &Ullman, Original edition, Pearson Publication. Virtual Labs of Data Structures https://www.vlab.co.in/broad-area-computer-science-and- engineering