SlideShare a Scribd company logo
1 of 17
Basic Traversal And Search
Techniques
Presented by
M.Kalai Selvi I-MSC[CS]
CONNECTED COMPONENTS
 A connected components is a subgraph in which any two
vertices are connected to each other by paths and which
is connected to no additional vertices of the super graph
ALGORITHM FOR CONNECTED COMPONENTS
 Connected components(G)
 For each vertex V G. G.V
 Make –set (V)
 For each edge (U,V) G.E
 If find –set(4) find-set(V)
 Union(U,V)
 Same Component(U,V)
 If find-set(U)= =find-set(V)
 Return true
 Else return false
DETERMINING CONNECTED COMPONENTS
void Graph::Components()
{
visited = new Boolean[n];
for(int i=0 ; i<n ; i++)
visited[i]= False;
for(i=0 ; i<n ; i++)
if(!visited[i])
{
DFS(i);
OutputNewComponent();
}
delete[]vivited;
}
GRAPHS
 Graphs are one of the most interesting data structures in
computer science
 Graths and tree are somewhat similar by their
structureand in fact tree is derived from the graph and
data structure
 Commonly used graph traversal algorithms are:
 DFS
 BFS
BFS
• In this we visit the node level by level
so it will start with 0, which is the root
node then next ,then the last level
• Queue is used to implement BFS
DFS
• In this we visit the root node first
then its children until it reaches
the end node
• Stack is used to implement DFS
SPANNING TREE
 Spanning tree have a connected undirected graph
 connected : every node reachable from every other node
 Undirected: edges do not have automatic direction
 Spanning tree of the graph is a connected sub -graph in
which there are no cycles
 A spanning of a graph has no cycles but still connects to
every house
 If G is a connected graph with n vertices and m edges,
spanning tree of G must have n-1 edges , and no.of edges
deleted from G to get a spanning tree must be m -(n-
1)=m-n+1
 A graph may have many spanning tree;for instance the
complete graph of four vertices.
A connected,
undirected graph
four of the spanning tree of the graph
BICONNECTED COMPONENTS
Basically it is a graph theory.
A graph is biconnected if it contains no
‘articulation’ points .
A components of a graph G is maximal
“biconnected subgraph”. That means it
is not contained any larger biconnected
subgraph of G
ARTICULATION POINTS
Let G = (V,E) be a connected
undirected graph.
Articulation point : is any vertex f G whose
removal result in a disconnected graph
BICONNECTED COMPONENTS
 A graph is biconnected if it contains no articulation
points.
DEFINITION
 The aim of the DFS algorithm is travers the graph in
such a way that is try to go for from the root node. Stack
is use in the implementation of the DFS. lets see hoe
DFS work with respect to the following graph.
 DFS – Depth First Search
 It implements stack, the concept of LIFO – Last In First
Out.
UN DIRECTED GRAPH
 Let G = (N,A)be an undirected graph all of whose nodes
we wish to visit
 To carry out a depth first traversal of the graph choose
any node V N as the starting point
DIRECTED GRAPH
 The algorithm is essentially the same as for undirected
graph , the different residing in the interpretation of the
word “adjacent”.
 In a directed graph, node W is an adjacent to node V but
is not adjacent to W
DSA ppt.pptx

More Related Content

Similar to DSA ppt.pptx

Graph theory concepts complex networks presents-rouhollah nabati
Graph theory concepts   complex networks presents-rouhollah nabatiGraph theory concepts   complex networks presents-rouhollah nabati
Graph theory concepts complex networks presents-rouhollah nabatinabati
 
Graph terminology and algorithm and tree.pptx
Graph terminology and algorithm and tree.pptxGraph terminology and algorithm and tree.pptx
Graph terminology and algorithm and tree.pptxasimshahzad8611
 
NON-LINEAR DATA STRUCTURE-Graphs.pptx
NON-LINEAR DATA STRUCTURE-Graphs.pptxNON-LINEAR DATA STRUCTURE-Graphs.pptx
NON-LINEAR DATA STRUCTURE-Graphs.pptxRajitha Reddy Alugati
 
05 Graphs In Job Assignment.-1 (1).pptx
05 Graphs In Job Assignment.-1 (1).pptx05 Graphs In Job Assignment.-1 (1).pptx
05 Graphs In Job Assignment.-1 (1).pptxRajnikantPandey11
 
Elements of Graph Theory for IS.pptx
Elements of Graph Theory for IS.pptxElements of Graph Theory for IS.pptx
Elements of Graph Theory for IS.pptxmiki304759
 
Graph applications chapter
Graph applications chapterGraph applications chapter
Graph applications chapterSavit Chandra
 
To find a non-split strong dominating set of an interval graph using an algor...
To find a non-split strong dominating set of an interval graph using an algor...To find a non-split strong dominating set of an interval graph using an algor...
To find a non-split strong dominating set of an interval graph using an algor...IOSR Journals
 
FADML 06 PPC Graphs and Traversals.pdf
FADML 06 PPC Graphs and Traversals.pdfFADML 06 PPC Graphs and Traversals.pdf
FADML 06 PPC Graphs and Traversals.pdfYelah1
 
Unit 3 graph chapter6
Unit 3  graph chapter6Unit 3  graph chapter6
Unit 3 graph chapter6DrkhanchanaR
 
Graph in Discrete mathemaetics.pptx
Graph in Discrete mathemaetics.pptxGraph in Discrete mathemaetics.pptx
Graph in Discrete mathemaetics.pptxujjwalmatoliya
 

Similar to DSA ppt.pptx (20)

Graph theory concepts complex networks presents-rouhollah nabati
Graph theory concepts   complex networks presents-rouhollah nabatiGraph theory concepts   complex networks presents-rouhollah nabati
Graph theory concepts complex networks presents-rouhollah nabati
 
Graph terminology and algorithm and tree.pptx
Graph terminology and algorithm and tree.pptxGraph terminology and algorithm and tree.pptx
Graph terminology and algorithm and tree.pptx
 
NON-LINEAR DATA STRUCTURE-Graphs.pptx
NON-LINEAR DATA STRUCTURE-Graphs.pptxNON-LINEAR DATA STRUCTURE-Graphs.pptx
NON-LINEAR DATA STRUCTURE-Graphs.pptx
 
09_DS_MCA_Graphs.pdf
09_DS_MCA_Graphs.pdf09_DS_MCA_Graphs.pdf
09_DS_MCA_Graphs.pdf
 
Graphs.pptx
Graphs.pptxGraphs.pptx
Graphs.pptx
 
05 Graphs In Job Assignment.-1 (1).pptx
05 Graphs In Job Assignment.-1 (1).pptx05 Graphs In Job Assignment.-1 (1).pptx
05 Graphs In Job Assignment.-1 (1).pptx
 
H0431038048
H0431038048H0431038048
H0431038048
 
Elements of Graph Theory for IS.pptx
Elements of Graph Theory for IS.pptxElements of Graph Theory for IS.pptx
Elements of Graph Theory for IS.pptx
 
Graphs
GraphsGraphs
Graphs
 
Lecture13
Lecture13Lecture13
Lecture13
 
Graph applications chapter
Graph applications chapterGraph applications chapter
Graph applications chapter
 
DATA STRUCTURES.pptx
DATA STRUCTURES.pptxDATA STRUCTURES.pptx
DATA STRUCTURES.pptx
 
8150.graphs
8150.graphs8150.graphs
8150.graphs
 
B0620510
B0620510B0620510
B0620510
 
To find a non-split strong dominating set of an interval graph using an algor...
To find a non-split strong dominating set of an interval graph using an algor...To find a non-split strong dominating set of an interval graph using an algor...
To find a non-split strong dominating set of an interval graph using an algor...
 
FADML 06 PPC Graphs and Traversals.pdf
FADML 06 PPC Graphs and Traversals.pdfFADML 06 PPC Graphs and Traversals.pdf
FADML 06 PPC Graphs and Traversals.pdf
 
Graphs
GraphsGraphs
Graphs
 
logic.pptx
logic.pptxlogic.pptx
logic.pptx
 
Unit 3 graph chapter6
Unit 3  graph chapter6Unit 3  graph chapter6
Unit 3 graph chapter6
 
Graph in Discrete mathemaetics.pptx
Graph in Discrete mathemaetics.pptxGraph in Discrete mathemaetics.pptx
Graph in Discrete mathemaetics.pptx
 

Recently uploaded

An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismDabee Kamal
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhleson0603
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnershipsexpandedwebsite
 
demyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptxdemyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptxMohamed Rizk Khodair
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjMohammed Sikander
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi RajagopalEADTU
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17Celine George
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...Gary Wood
 
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...Nguyen Thanh Tu Collection
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppCeline George
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17Celine George
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsSandeep D Chaudhary
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................MirzaAbrarBaig5
 
Climbers and Creepers used in landscaping
Climbers and Creepers used in landscapingClimbers and Creepers used in landscaping
Climbers and Creepers used in landscapingDr. M. Kumaresan Hort.
 
Scopus Indexed Journals 2024 - ISCOPUS Publications
Scopus Indexed Journals 2024 - ISCOPUS PublicationsScopus Indexed Journals 2024 - ISCOPUS Publications
Scopus Indexed Journals 2024 - ISCOPUS PublicationsISCOPE Publication
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....Ritu480198
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptxPoojaSen20
 

Recently uploaded (20)

An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 
demyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptxdemyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptx
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17
 
Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................
 
Climbers and Creepers used in landscaping
Climbers and Creepers used in landscapingClimbers and Creepers used in landscaping
Climbers and Creepers used in landscaping
 
Scopus Indexed Journals 2024 - ISCOPUS Publications
Scopus Indexed Journals 2024 - ISCOPUS PublicationsScopus Indexed Journals 2024 - ISCOPUS Publications
Scopus Indexed Journals 2024 - ISCOPUS Publications
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptx
 
Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"
 

DSA ppt.pptx

  • 1. Basic Traversal And Search Techniques Presented by M.Kalai Selvi I-MSC[CS]
  • 2.
  • 3. CONNECTED COMPONENTS  A connected components is a subgraph in which any two vertices are connected to each other by paths and which is connected to no additional vertices of the super graph
  • 4. ALGORITHM FOR CONNECTED COMPONENTS  Connected components(G)  For each vertex V G. G.V  Make –set (V)  For each edge (U,V) G.E  If find –set(4) find-set(V)  Union(U,V)  Same Component(U,V)  If find-set(U)= =find-set(V)  Return true  Else return false
  • 5. DETERMINING CONNECTED COMPONENTS void Graph::Components() { visited = new Boolean[n]; for(int i=0 ; i<n ; i++) visited[i]= False; for(i=0 ; i<n ; i++) if(!visited[i]) { DFS(i); OutputNewComponent(); } delete[]vivited; }
  • 6. GRAPHS  Graphs are one of the most interesting data structures in computer science  Graths and tree are somewhat similar by their structureand in fact tree is derived from the graph and data structure  Commonly used graph traversal algorithms are:  DFS  BFS
  • 7. BFS • In this we visit the node level by level so it will start with 0, which is the root node then next ,then the last level • Queue is used to implement BFS DFS • In this we visit the root node first then its children until it reaches the end node • Stack is used to implement DFS
  • 8. SPANNING TREE  Spanning tree have a connected undirected graph  connected : every node reachable from every other node  Undirected: edges do not have automatic direction  Spanning tree of the graph is a connected sub -graph in which there are no cycles  A spanning of a graph has no cycles but still connects to every house  If G is a connected graph with n vertices and m edges, spanning tree of G must have n-1 edges , and no.of edges deleted from G to get a spanning tree must be m -(n- 1)=m-n+1
  • 9.  A graph may have many spanning tree;for instance the complete graph of four vertices. A connected, undirected graph four of the spanning tree of the graph
  • 10. BICONNECTED COMPONENTS Basically it is a graph theory. A graph is biconnected if it contains no ‘articulation’ points . A components of a graph G is maximal “biconnected subgraph”. That means it is not contained any larger biconnected subgraph of G
  • 11. ARTICULATION POINTS Let G = (V,E) be a connected undirected graph. Articulation point : is any vertex f G whose removal result in a disconnected graph
  • 12. BICONNECTED COMPONENTS  A graph is biconnected if it contains no articulation points.
  • 13.
  • 14. DEFINITION  The aim of the DFS algorithm is travers the graph in such a way that is try to go for from the root node. Stack is use in the implementation of the DFS. lets see hoe DFS work with respect to the following graph.  DFS – Depth First Search  It implements stack, the concept of LIFO – Last In First Out.
  • 15. UN DIRECTED GRAPH  Let G = (N,A)be an undirected graph all of whose nodes we wish to visit  To carry out a depth first traversal of the graph choose any node V N as the starting point
  • 16. DIRECTED GRAPH  The algorithm is essentially the same as for undirected graph , the different residing in the interpretation of the word “adjacent”.  In a directed graph, node W is an adjacent to node V but is not adjacent to W