SlideShare a Scribd company logo
1 of 14
DEPTH FIRST SEARCH
(DFS)
PADA GRAPH
Algoritma dan Struktur
Data
Dr. Achmad Solichin,
S.Kom, M.T.I
GRAPH
V = {0, 1, 2, 3}
E = {(0,1), (0,2), (0,3), (1,2)}
G = {V, E}
Indirect Graph
GRAPH TERMINOLOGY
 Adjacency: A vertex is said to be adjacent to another vertex if
there is an edge connecting them. Vertices 2 and 3 are not
adjacent because there is no edge between them.
 Path: A sequence of edges that allows you to go from vertex A
to vertex B is called a path. 0-1, 1-2 and 0-2 are paths from
vertex 0 to vertex 2.
 Directed Graph: A graph in which an edge (u,v) doesn't
necessarily mean that there is an edge (v, u) as well. The
edges in such a graph are represented by arrows to show the
direction of the edge.
GRAPH REPRESENTATION
1. Adjacency Matrix 2. Adjacency List
DEPTH FIRST SEARCH (DFS)
ALGORITHM
The DFS algorithm works as follows:
1. Start by putting any one of the graph's vertices on top of a
stack.
2. Take the top item of the stack and add it to the visited list.
3. Create a list of that vertex's adjacent nodes. Add the ones
which aren't in the visited list to the top of the stack.
4. Keep repeating steps 2 and 3 until the stack is empty.
STEP BY STEP DFS ALGORITHM – 1
We use an undirected graph with 5 vertices
STEP BY STEP DFS ALGORITHM – 2
We start from vertex 0, the DFS algorithm starts by
putting it in the Visited list and putting all its
adjacent vertices in the stack.
STEP BY STEP DFS ALGORITHM – 3
Next, we visit the element at the top of stack i.e. 1
and go to its adjacent nodes. Since 0 has already
been visited, we visit 2 instead.
STEP BY STEP DFS ALGORITHM – 4
Vertex 2 has an unvisited adjacent vertex in 4, so we
add that to the top of the stack and visit it.
STEP BY STEP DFS ALGORITHM – 5
After we visit the last element 3, it doesn't have any
unvisited adjacent nodes, so we have completed the
Depth First Traversal of the graph.
DFS PSEUDOCODE (RECURSIVE)
DFS IMPLEMENTATION IN
PROGRAMMING
C C++ Java
https://qrgo.page.link/j1RFQhttps://qrgo.page.link/hDBjqhttps://qrgo.page.link/dxkr1
REFERENCES
 Slide “Graph: Pemahaman dan Konsep Dasar Graph – Algoritma dan
Struktur Data 3” by Moh. Sjukani (Universitas Budi Luhur)
 Slide “Graph Traversal (Penelusuran Graph) – Algoritma dan Struktur
Data 3” by Achmad Solichin (Universitas Budi Luhur)
 DFS Algorithm - https://www.programiz.com/dsa/graph-dfs
TERIMA KASIH
 Dr. Achmad Solichin, S.Kom., M.T.I.
 Fakultas Teknologi Informasi, Universitas Budi Luhur
 achmatim@gmail.com | Achmad.Solichin@budiluhur.ac.id
 http://achmatim.net

More Related Content

What's hot

nilai eigen dan vektor eigen
nilai eigen dan vektor eigennilai eigen dan vektor eigen
nilai eigen dan vektor eigenelmabb
 
Algoritma pemrograman 2 - Contoh program"Struct Data Karyawan"
Algoritma pemrograman 2 - Contoh program"Struct Data Karyawan"Algoritma pemrograman 2 - Contoh program"Struct Data Karyawan"
Algoritma pemrograman 2 - Contoh program"Struct Data Karyawan"Derina Ellya R
 
CFG dan PARSING - P 5 - Teknik Kompilasi
CFG dan PARSING - P 5 - Teknik KompilasiCFG dan PARSING - P 5 - Teknik Kompilasi
CFG dan PARSING - P 5 - Teknik Kompilasiahmad haidaroh
 
Algoritma pencarian lintasan jalur terpendek
Algoritma pencarian lintasan jalur terpendekAlgoritma pencarian lintasan jalur terpendek
Algoritma pencarian lintasan jalur terpendekLaili Wahyunita
 
Materi linked list dan bubble sort
Materi linked list dan bubble sortMateri linked list dan bubble sort
Materi linked list dan bubble sortYunan Helmi Nasution
 
Materi 4 penyelesaian spl tiga atau lebih variabel
Materi 4 penyelesaian spl tiga atau lebih variabelMateri 4 penyelesaian spl tiga atau lebih variabel
Materi 4 penyelesaian spl tiga atau lebih variabelradar radius
 
mencari nilai minimum menggunakan fungsi rekursif di C
mencari nilai minimum menggunakan fungsi rekursif di Cmencari nilai minimum menggunakan fungsi rekursif di C
mencari nilai minimum menggunakan fungsi rekursif di Ckir yy
 
Makalah Kegunaan Matematika Diskrit pada Teknik Informatika
Makalah Kegunaan Matematika Diskrit pada Teknik InformatikaMakalah Kegunaan Matematika Diskrit pada Teknik Informatika
Makalah Kegunaan Matematika Diskrit pada Teknik Informatikasaid zulhelmi
 
Makalah metode posisi palsu
Makalah metode posisi palsuMakalah metode posisi palsu
Makalah metode posisi palsuokti agung
 
Pengertian dan Representasi Graph
Pengertian dan Representasi GraphPengertian dan Representasi Graph
Pengertian dan Representasi GraphZaldy Eka Putra
 
Matematika Diskrit - 09 graf - 08
Matematika Diskrit - 09 graf - 08Matematika Diskrit - 09 graf - 08
Matematika Diskrit - 09 graf - 08KuliahKita
 
Matematika Diskrit - 06 relasi dan fungsi - 05
Matematika Diskrit - 06 relasi dan fungsi - 05Matematika Diskrit - 06 relasi dan fungsi - 05
Matematika Diskrit - 06 relasi dan fungsi - 05KuliahKita
 
Sub grup normal dan grup fakto
Sub grup normal dan grup faktoSub grup normal dan grup fakto
Sub grup normal dan grup faktoYadi Pura
 
Tugas mandiri struktur data
Tugas mandiri struktur dataTugas mandiri struktur data
Tugas mandiri struktur dataAsep Jaenudin
 
Order dari Elemen Grup
Order dari Elemen GrupOrder dari Elemen Grup
Order dari Elemen Grupwahyuhenky
 
Graf ( Matematika Diskrit)
Graf ( Matematika Diskrit)Graf ( Matematika Diskrit)
Graf ( Matematika Diskrit)zachrison htg
 
Pertemuan 4-metode-pencarian-dan-pelacakan
Pertemuan 4-metode-pencarian-dan-pelacakanPertemuan 4-metode-pencarian-dan-pelacakan
Pertemuan 4-metode-pencarian-dan-pelacakanwillyhayon
 
Bab2 peubah-acak-dan-distribusi-peluang
Bab2 peubah-acak-dan-distribusi-peluangBab2 peubah-acak-dan-distribusi-peluang
Bab2 peubah-acak-dan-distribusi-peluangArif Windiargo
 

What's hot (20)

nilai eigen dan vektor eigen
nilai eigen dan vektor eigennilai eigen dan vektor eigen
nilai eigen dan vektor eigen
 
Algoritma pemrograman 2 - Contoh program"Struct Data Karyawan"
Algoritma pemrograman 2 - Contoh program"Struct Data Karyawan"Algoritma pemrograman 2 - Contoh program"Struct Data Karyawan"
Algoritma pemrograman 2 - Contoh program"Struct Data Karyawan"
 
CFG dan PARSING - P 5 - Teknik Kompilasi
CFG dan PARSING - P 5 - Teknik KompilasiCFG dan PARSING - P 5 - Teknik Kompilasi
CFG dan PARSING - P 5 - Teknik Kompilasi
 
Algoritma pencarian lintasan jalur terpendek
Algoritma pencarian lintasan jalur terpendekAlgoritma pencarian lintasan jalur terpendek
Algoritma pencarian lintasan jalur terpendek
 
Materi linked list dan bubble sort
Materi linked list dan bubble sortMateri linked list dan bubble sort
Materi linked list dan bubble sort
 
Materi 4 penyelesaian spl tiga atau lebih variabel
Materi 4 penyelesaian spl tiga atau lebih variabelMateri 4 penyelesaian spl tiga atau lebih variabel
Materi 4 penyelesaian spl tiga atau lebih variabel
 
mencari nilai minimum menggunakan fungsi rekursif di C
mencari nilai minimum menggunakan fungsi rekursif di Cmencari nilai minimum menggunakan fungsi rekursif di C
mencari nilai minimum menggunakan fungsi rekursif di C
 
Makalah Kegunaan Matematika Diskrit pada Teknik Informatika
Makalah Kegunaan Matematika Diskrit pada Teknik InformatikaMakalah Kegunaan Matematika Diskrit pada Teknik Informatika
Makalah Kegunaan Matematika Diskrit pada Teknik Informatika
 
Makalah metode posisi palsu
Makalah metode posisi palsuMakalah metode posisi palsu
Makalah metode posisi palsu
 
Pengertian dan Representasi Graph
Pengertian dan Representasi GraphPengertian dan Representasi Graph
Pengertian dan Representasi Graph
 
Matematika Diskrit - 09 graf - 08
Matematika Diskrit - 09 graf - 08Matematika Diskrit - 09 graf - 08
Matematika Diskrit - 09 graf - 08
 
Matematika Diskrit - 06 relasi dan fungsi - 05
Matematika Diskrit - 06 relasi dan fungsi - 05Matematika Diskrit - 06 relasi dan fungsi - 05
Matematika Diskrit - 06 relasi dan fungsi - 05
 
Struktur Data Tree
Struktur Data TreeStruktur Data Tree
Struktur Data Tree
 
Sub grup normal dan grup fakto
Sub grup normal dan grup faktoSub grup normal dan grup fakto
Sub grup normal dan grup fakto
 
Tugas mandiri struktur data
Tugas mandiri struktur dataTugas mandiri struktur data
Tugas mandiri struktur data
 
Order dari Elemen Grup
Order dari Elemen GrupOrder dari Elemen Grup
Order dari Elemen Grup
 
Graf ( Matematika Diskrit)
Graf ( Matematika Diskrit)Graf ( Matematika Diskrit)
Graf ( Matematika Diskrit)
 
Bab 4 aljabar boolean
Bab 4 aljabar booleanBab 4 aljabar boolean
Bab 4 aljabar boolean
 
Pertemuan 4-metode-pencarian-dan-pelacakan
Pertemuan 4-metode-pencarian-dan-pelacakanPertemuan 4-metode-pencarian-dan-pelacakan
Pertemuan 4-metode-pencarian-dan-pelacakan
 
Bab2 peubah-acak-dan-distribusi-peluang
Bab2 peubah-acak-dan-distribusi-peluangBab2 peubah-acak-dan-distribusi-peluang
Bab2 peubah-acak-dan-distribusi-peluang
 

Similar to DFS ALGORITHM EXPLAINED

Similar to DFS ALGORITHM EXPLAINED (20)

Breadth First Search (BFS) pada Graph
Breadth First Search (BFS) pada GraphBreadth First Search (BFS) pada Graph
Breadth First Search (BFS) pada Graph
 
Graphs
GraphsGraphs
Graphs
 
Topological Sort and BFS
Topological Sort and BFSTopological Sort and BFS
Topological Sort and BFS
 
Graph Theory
Graph TheoryGraph Theory
Graph Theory
 
Analysis & design of algorithm
Analysis & design of algorithmAnalysis & design of algorithm
Analysis & design of algorithm
 
Data structure note
Data structure noteData structure note
Data structure note
 
logic.pptx
logic.pptxlogic.pptx
logic.pptx
 
DATA STRUCTURES.pptx
DATA STRUCTURES.pptxDATA STRUCTURES.pptx
DATA STRUCTURES.pptx
 
Unit V - ppt.pptx
Unit V - ppt.pptxUnit V - ppt.pptx
Unit V - ppt.pptx
 
Strongly connected components
Strongly connected componentsStrongly connected components
Strongly connected components
 
UNIT III.pptx
UNIT III.pptxUNIT III.pptx
UNIT III.pptx
 
Daa chpater 12
Daa chpater 12Daa chpater 12
Daa chpater 12
 
Graphs
GraphsGraphs
Graphs
 
NON-LINEAR DATA STRUCTURE-Graphs.pptx
NON-LINEAR DATA STRUCTURE-Graphs.pptxNON-LINEAR DATA STRUCTURE-Graphs.pptx
NON-LINEAR DATA STRUCTURE-Graphs.pptx
 
Graphs
GraphsGraphs
Graphs
 
Unit-6 Graph.ppsx ppt
Unit-6 Graph.ppsx                                       pptUnit-6 Graph.ppsx                                       ppt
Unit-6 Graph.ppsx ppt
 
data structures and algorithms Unit 2
data structures and algorithms Unit 2data structures and algorithms Unit 2
data structures and algorithms Unit 2
 
Vanmathy no sql
Vanmathy no sql Vanmathy no sql
Vanmathy no sql
 
VANU no sql ppt.pptx
VANU no sql ppt.pptxVANU no sql ppt.pptx
VANU no sql ppt.pptx
 
Graph Traversal Algorithms - Depth First Search Traversal
Graph Traversal Algorithms - Depth First Search TraversalGraph Traversal Algorithms - Depth First Search Traversal
Graph Traversal Algorithms - Depth First Search Traversal
 

More from Achmad Solichin

Kuliah Umum - Tips Publikasi Jurnal SINTA untuk Mahasiswa Galau (6 Agustus 2022)
Kuliah Umum - Tips Publikasi Jurnal SINTA untuk Mahasiswa Galau (6 Agustus 2022)Kuliah Umum - Tips Publikasi Jurnal SINTA untuk Mahasiswa Galau (6 Agustus 2022)
Kuliah Umum - Tips Publikasi Jurnal SINTA untuk Mahasiswa Galau (6 Agustus 2022)Achmad Solichin
 
Materi Webinar Web 3.0 (16 Juli 2022)
Materi Webinar Web 3.0 (16 Juli 2022)Materi Webinar Web 3.0 (16 Juli 2022)
Materi Webinar Web 3.0 (16 Juli 2022)Achmad Solichin
 
Webinar: Kesadaran Keamanan Informasi (3 Desember 2021)
Webinar: Kesadaran Keamanan Informasi (3 Desember 2021)Webinar: Kesadaran Keamanan Informasi (3 Desember 2021)
Webinar: Kesadaran Keamanan Informasi (3 Desember 2021)Achmad Solichin
 
Webinar PHP-ID: Mari Mengenal Logika Fuzzy (Fuzzy Logic)
Webinar PHP-ID: Mari Mengenal Logika Fuzzy (Fuzzy Logic)Webinar PHP-ID: Mari Mengenal Logika Fuzzy (Fuzzy Logic)
Webinar PHP-ID: Mari Mengenal Logika Fuzzy (Fuzzy Logic)Achmad Solichin
 
Webinar PHP-ID: Machine Learning dengan PHP
Webinar PHP-ID: Machine Learning dengan PHPWebinar PHP-ID: Machine Learning dengan PHP
Webinar PHP-ID: Machine Learning dengan PHPAchmad Solichin
 
Webinar Data Mining dengan Rapidminer | Universitas Budi Luhur
Webinar Data Mining dengan Rapidminer | Universitas Budi LuhurWebinar Data Mining dengan Rapidminer | Universitas Budi Luhur
Webinar Data Mining dengan Rapidminer | Universitas Budi LuhurAchmad Solichin
 
TREN DAN IDE RISET BIDANG DATA MINING TERBARU
TREN DAN IDE RISET BIDANG DATA MINING TERBARUTREN DAN IDE RISET BIDANG DATA MINING TERBARU
TREN DAN IDE RISET BIDANG DATA MINING TERBARUAchmad Solichin
 
Metodologi Riset: Literature Review
Metodologi Riset: Literature ReviewMetodologi Riset: Literature Review
Metodologi Riset: Literature ReviewAchmad Solichin
 
Materi Seminar: Artificial Intelligence dengan PHP
Materi Seminar: Artificial Intelligence dengan PHPMateri Seminar: Artificial Intelligence dengan PHP
Materi Seminar: Artificial Intelligence dengan PHPAchmad Solichin
 
Percobaan Perpindahan Kalor melalui Konduksi, Konveksi dan Radiasi
Percobaan Perpindahan Kalor melalui Konduksi, Konveksi dan RadiasiPercobaan Perpindahan Kalor melalui Konduksi, Konveksi dan Radiasi
Percobaan Perpindahan Kalor melalui Konduksi, Konveksi dan RadiasiAchmad Solichin
 
Metodologi Riset: Literature Review
Metodologi Riset: Literature ReviewMetodologi Riset: Literature Review
Metodologi Riset: Literature ReviewAchmad Solichin
 
Computer Vision di Era Industri 4.0
Computer Vision di Era Industri 4.0Computer Vision di Era Industri 4.0
Computer Vision di Era Industri 4.0Achmad Solichin
 
Seminar: Become a Reliable Web Programmer
Seminar: Become a Reliable Web ProgrammerSeminar: Become a Reliable Web Programmer
Seminar: Become a Reliable Web ProgrammerAchmad Solichin
 
The Big 5: Future IT Trends
The Big 5: Future IT TrendsThe Big 5: Future IT Trends
The Big 5: Future IT TrendsAchmad Solichin
 
Seminar: PHP Developer for Dummies
Seminar: PHP Developer for DummiesSeminar: PHP Developer for Dummies
Seminar: PHP Developer for DummiesAchmad Solichin
 
Pertemuan 1 - Algoritma dan Struktur Data 1
Pertemuan 1 - Algoritma dan Struktur Data 1Pertemuan 1 - Algoritma dan Struktur Data 1
Pertemuan 1 - Algoritma dan Struktur Data 1Achmad Solichin
 
Sharing Penelitian S3 Lab Elins FMIPA UGM - 17 Februari 2016
Sharing Penelitian S3 Lab Elins FMIPA UGM - 17 Februari 2016Sharing Penelitian S3 Lab Elins FMIPA UGM - 17 Februari 2016
Sharing Penelitian S3 Lab Elins FMIPA UGM - 17 Februari 2016Achmad Solichin
 
Seminar: Mau jadi Android User atau Developer?
Seminar: Mau jadi Android User atau Developer?Seminar: Mau jadi Android User atau Developer?
Seminar: Mau jadi Android User atau Developer?Achmad Solichin
 
Workshop PHP: Laporan HTML, Excel, PDF
Workshop PHP: Laporan HTML, Excel, PDFWorkshop PHP: Laporan HTML, Excel, PDF
Workshop PHP: Laporan HTML, Excel, PDFAchmad Solichin
 

More from Achmad Solichin (20)

Kuliah Umum - Tips Publikasi Jurnal SINTA untuk Mahasiswa Galau (6 Agustus 2022)
Kuliah Umum - Tips Publikasi Jurnal SINTA untuk Mahasiswa Galau (6 Agustus 2022)Kuliah Umum - Tips Publikasi Jurnal SINTA untuk Mahasiswa Galau (6 Agustus 2022)
Kuliah Umum - Tips Publikasi Jurnal SINTA untuk Mahasiswa Galau (6 Agustus 2022)
 
Materi Webinar Web 3.0 (16 Juli 2022)
Materi Webinar Web 3.0 (16 Juli 2022)Materi Webinar Web 3.0 (16 Juli 2022)
Materi Webinar Web 3.0 (16 Juli 2022)
 
Webinar: Kesadaran Keamanan Informasi (3 Desember 2021)
Webinar: Kesadaran Keamanan Informasi (3 Desember 2021)Webinar: Kesadaran Keamanan Informasi (3 Desember 2021)
Webinar: Kesadaran Keamanan Informasi (3 Desember 2021)
 
Webinar PHP-ID: Mari Mengenal Logika Fuzzy (Fuzzy Logic)
Webinar PHP-ID: Mari Mengenal Logika Fuzzy (Fuzzy Logic)Webinar PHP-ID: Mari Mengenal Logika Fuzzy (Fuzzy Logic)
Webinar PHP-ID: Mari Mengenal Logika Fuzzy (Fuzzy Logic)
 
Webinar PHP-ID: Machine Learning dengan PHP
Webinar PHP-ID: Machine Learning dengan PHPWebinar PHP-ID: Machine Learning dengan PHP
Webinar PHP-ID: Machine Learning dengan PHP
 
Webinar Data Mining dengan Rapidminer | Universitas Budi Luhur
Webinar Data Mining dengan Rapidminer | Universitas Budi LuhurWebinar Data Mining dengan Rapidminer | Universitas Budi Luhur
Webinar Data Mining dengan Rapidminer | Universitas Budi Luhur
 
TREN DAN IDE RISET BIDANG DATA MINING TERBARU
TREN DAN IDE RISET BIDANG DATA MINING TERBARUTREN DAN IDE RISET BIDANG DATA MINING TERBARU
TREN DAN IDE RISET BIDANG DATA MINING TERBARU
 
Metodologi Riset: Literature Review
Metodologi Riset: Literature ReviewMetodologi Riset: Literature Review
Metodologi Riset: Literature Review
 
Materi Seminar: Artificial Intelligence dengan PHP
Materi Seminar: Artificial Intelligence dengan PHPMateri Seminar: Artificial Intelligence dengan PHP
Materi Seminar: Artificial Intelligence dengan PHP
 
Percobaan Perpindahan Kalor melalui Konduksi, Konveksi dan Radiasi
Percobaan Perpindahan Kalor melalui Konduksi, Konveksi dan RadiasiPercobaan Perpindahan Kalor melalui Konduksi, Konveksi dan Radiasi
Percobaan Perpindahan Kalor melalui Konduksi, Konveksi dan Radiasi
 
Metodologi Riset: Literature Review
Metodologi Riset: Literature ReviewMetodologi Riset: Literature Review
Metodologi Riset: Literature Review
 
Computer Vision di Era Industri 4.0
Computer Vision di Era Industri 4.0Computer Vision di Era Industri 4.0
Computer Vision di Era Industri 4.0
 
Seminar: Become a Reliable Web Programmer
Seminar: Become a Reliable Web ProgrammerSeminar: Become a Reliable Web Programmer
Seminar: Become a Reliable Web Programmer
 
The Big 5: Future IT Trends
The Big 5: Future IT TrendsThe Big 5: Future IT Trends
The Big 5: Future IT Trends
 
Modern PHP Developer
Modern PHP DeveloperModern PHP Developer
Modern PHP Developer
 
Seminar: PHP Developer for Dummies
Seminar: PHP Developer for DummiesSeminar: PHP Developer for Dummies
Seminar: PHP Developer for Dummies
 
Pertemuan 1 - Algoritma dan Struktur Data 1
Pertemuan 1 - Algoritma dan Struktur Data 1Pertemuan 1 - Algoritma dan Struktur Data 1
Pertemuan 1 - Algoritma dan Struktur Data 1
 
Sharing Penelitian S3 Lab Elins FMIPA UGM - 17 Februari 2016
Sharing Penelitian S3 Lab Elins FMIPA UGM - 17 Februari 2016Sharing Penelitian S3 Lab Elins FMIPA UGM - 17 Februari 2016
Sharing Penelitian S3 Lab Elins FMIPA UGM - 17 Februari 2016
 
Seminar: Mau jadi Android User atau Developer?
Seminar: Mau jadi Android User atau Developer?Seminar: Mau jadi Android User atau Developer?
Seminar: Mau jadi Android User atau Developer?
 
Workshop PHP: Laporan HTML, Excel, PDF
Workshop PHP: Laporan HTML, Excel, PDFWorkshop PHP: Laporan HTML, Excel, PDF
Workshop PHP: Laporan HTML, Excel, PDF
 

Recently uploaded

Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxsqpmdrvczh
 
ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationAadityaSharma884161
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........LeaCamillePacle
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxLigayaBacuel1
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 

Recently uploaded (20)

Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptx
 
ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint Presentation
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"
 
Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptx
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 

DFS ALGORITHM EXPLAINED

  • 1. DEPTH FIRST SEARCH (DFS) PADA GRAPH Algoritma dan Struktur Data Dr. Achmad Solichin, S.Kom, M.T.I
  • 2. GRAPH V = {0, 1, 2, 3} E = {(0,1), (0,2), (0,3), (1,2)} G = {V, E} Indirect Graph
  • 3. GRAPH TERMINOLOGY  Adjacency: A vertex is said to be adjacent to another vertex if there is an edge connecting them. Vertices 2 and 3 are not adjacent because there is no edge between them.  Path: A sequence of edges that allows you to go from vertex A to vertex B is called a path. 0-1, 1-2 and 0-2 are paths from vertex 0 to vertex 2.  Directed Graph: A graph in which an edge (u,v) doesn't necessarily mean that there is an edge (v, u) as well. The edges in such a graph are represented by arrows to show the direction of the edge.
  • 4. GRAPH REPRESENTATION 1. Adjacency Matrix 2. Adjacency List
  • 5. DEPTH FIRST SEARCH (DFS) ALGORITHM The DFS algorithm works as follows: 1. Start by putting any one of the graph's vertices on top of a stack. 2. Take the top item of the stack and add it to the visited list. 3. Create a list of that vertex's adjacent nodes. Add the ones which aren't in the visited list to the top of the stack. 4. Keep repeating steps 2 and 3 until the stack is empty.
  • 6. STEP BY STEP DFS ALGORITHM – 1 We use an undirected graph with 5 vertices
  • 7. STEP BY STEP DFS ALGORITHM – 2 We start from vertex 0, the DFS algorithm starts by putting it in the Visited list and putting all its adjacent vertices in the stack.
  • 8. STEP BY STEP DFS ALGORITHM – 3 Next, we visit the element at the top of stack i.e. 1 and go to its adjacent nodes. Since 0 has already been visited, we visit 2 instead.
  • 9. STEP BY STEP DFS ALGORITHM – 4 Vertex 2 has an unvisited adjacent vertex in 4, so we add that to the top of the stack and visit it.
  • 10. STEP BY STEP DFS ALGORITHM – 5 After we visit the last element 3, it doesn't have any unvisited adjacent nodes, so we have completed the Depth First Traversal of the graph.
  • 12. DFS IMPLEMENTATION IN PROGRAMMING C C++ Java https://qrgo.page.link/j1RFQhttps://qrgo.page.link/hDBjqhttps://qrgo.page.link/dxkr1
  • 13. REFERENCES  Slide “Graph: Pemahaman dan Konsep Dasar Graph – Algoritma dan Struktur Data 3” by Moh. Sjukani (Universitas Budi Luhur)  Slide “Graph Traversal (Penelusuran Graph) – Algoritma dan Struktur Data 3” by Achmad Solichin (Universitas Budi Luhur)  DFS Algorithm - https://www.programiz.com/dsa/graph-dfs
  • 14. TERIMA KASIH  Dr. Achmad Solichin, S.Kom., M.T.I.  Fakultas Teknologi Informasi, Universitas Budi Luhur  achmatim@gmail.com | Achmad.Solichin@budiluhur.ac.id  http://achmatim.net