SlideShare a Scribd company logo
Dfs presentation
Dfs presentation
Dfs presentation
Dfs presentation
Definition
Process
Algorithmic steps
Example
Code
Time Complexity
Advantages
Disadvantages
Definition
Process
Algorithmic steps
Example
Code
Time Complexity
Advantages
Disadvantages
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 depth first search. Lets see how depth
first search work with respect to the following
graph.
Un Directed graph

a

d

b
e

c

f
Definition
Process
Algorithmic steps
Example
Code
Time Complexity
Advantages
Disadvantages
Process
As stated before in DFS nodes are visited by
going through the depth of the tree from the
starting node if we do the depth first traversal of
the above graph and print the visited node it will
be “ A B C D E F CD “ DFS visited the root node
then its children nodes until it reach the end node
E and F them moves up to the parents nodes
Definition
Process
Algorithmic steps
Example
Code
Time Complexity
Advantages
Disadvantages
Algorithm steps
Step:1
Push the root node in stack.
Step:2
Loop until stack is empty.
Step:3
Peek the node of the stack.
Step:4

If the node has unvisited child nodes get the
unvisited child node mark it has travers and push it on
stack.
Definition
Process
Algorithmic steps
Example
Code
Time Complexity
Advantages
Disadvantages
Example
Directed graph
Dfs presentation
DIRECTED DEPTH FIRST SEARCH
A

B

H

C

G

I
D

F

E

dfs(A)
A-F A-G

Function call stack:
DIRECTED DEPTH FIRST SEARCH
A

B

H

C

G

I
D

F

visit(F)

E

F-E

dfs(A)
A-F A-G
Function call stack:
DIRECTED DEPTH FIRST SEARCH
A

B

H

C

G

I
D

dfs(E)
E-C E-D E-G

F

E

dfs(F)

F-E

dfs(A)
A-F A-G
Function call stack:
DIRECTED DEPTH FIRST SEARCH
A

B

H

C

G

dfs(C)
I

C-A C-D
D

dfs(E)
E-C E-D E-G

F

E

dfs(F)
F-E
dfs(A)

A-F A-G
Function call stack:
DIRECTED DEPTH FIRST SEARCH
A

B

H

C

G

dfs(C)
I

C-A C-D
D

dfs(E)
E-C E-D E-G

F

E

dfs(F)
F-E
dfs(A)

A-F A-G
Function call stack:
DIRECTED DEPTH FIRST SEARCH
dfs(D)

A

D-C D-F

B

H

dfs(C)
C

G

C-A C-D

I

dfs(E)

D

E-C E-D E-G
F

E

dfs(F)
F-E

dfs(A)
A-F A-G
Function call stack:
DIRECTED DEPTH FIRST SEARCH
A

dfs(D)
B

H

C

G

D-C D-F
dfs(C)

I

C-A C-D
D

dfs(E)
E-C E-D E-G

F

E

dfs(F)
F-E
dfs(A)

A-F A-G
Function call stack:
DIRECTED DEPTH FIRST SEARCH
dfs(D)

A

D-C D-F

dfs(C)
B

H

C

G

C-A C-D

I

dfs(E)

D

E-C E-D E-G
E

F

dfs(F)
F-E

dfs(A)
Function call stack:

A-F A-G
DIRECTED DEPTH FIRST SEARCH
A

dfs(C)
B

H

C

I

dfs(E)
D

F

C-A C-D

G

E-C E-D E-G
E

dfs(F)
F-E

dfs(A)
A-F A-G
Function call stack:
DIRECTED DEPTH FIRST SEARCH
A

B

H

C

G

I

dfs(E)
D

F

E-C E-D E-G

E

dfs(F)
F-E

dfs(A)
A-F A-G
Function call stack:
DIRECTED DEPTH FIRST SEARCH
A

B

H

C

G

I

dfs(E)
D

F

E-C E-D E-G
E

dfs(F)
F-E

dfs(A)
A-F A-G
Function call stack:
DIRECTED DEPTH FIRST SEARCH
A

dfs(G)
B

H

C

G

dfs(E)

I

E-C E-D E-G

D

F

E

dfs(F)
F-E

dfs(A)
A-F A-G
Function call stack:
DIRECTED DEPTH FIRST SEARCH
A

B

H

C

dfs(E)

I

E-C E-D E-G

D

F

G

E

dfs(F)
F-E

dfs(A)
A-F A-G
Function call stack:
DIRECTED DEPTH FIRST SEARCH
A

B

H

C

G

I
D

dfs(F)
F

E

F-E

dfs(A)
A-F A-G
Function call stack:
DIRECTED DEPTH FIRST SEARCH
A

B

H

C

G

I
D

F

E

dfs(A)

A-F A-G
Function call stack:
DIRECTED DEPTH FIRST SEARCH
A

B

H

C

G

I
D

F

E

dfs(A)

A-F A-G
Function call stack:
DIRECTED DEPTH FIRST SEARCH
A

B

H

C

G

I
D

F

E

Nodes reachable from A: A, C, D, E, F, G
DIRECTED DEPTH FIRST SEARCH
A

B

H

C

G

I
D

F

E

Nodes reachable from A: A, C, D, E, F, G
Definition
Process
Algorithmic steps
Example
Code
Time Complexity
Advantages
Disadvantages
Time Complexity
Assume that graph is connected. Depth-first search visits every vertex
in the graph and checks every edge its edge. Therefore, DFS
complexity is O(V + E). As it was mentioned before, if an adjacency
matrix is used for a graph representation, then all edges, adjacent to a
vertex can't be found efficiently, that results in O(V2) complexity.
Definition
Process
Algorithmic steps
Example
Code
Time Complexity
Advantages
Disadvantages
Advantage of depth first search
• The advantage of depth-first Search is that memory requirement is only linear
with respect to the search graph. This is in contrast with breadth-first search
which requires more space. The reason is that the algorithm only needs to store a
stack of nodes on the path from the root to the current node.
• The time complexity of a depth-first Search to depth d is O(b^d) since it
generates the same set of nodes as breadth-first search, but simply in a different
order. Thus practically depth-first search is time-limited rather than space-limited.
• If depth-first search finds solution without exploring much in a path then the
time and space it takes will be very less.
Definition
Process
Algorithmic steps
Example
Code
Time Complexity
Advantages
Disadvantages
Disadvantages
• The disadvantage of Depth-First Search is that there is a possibility that it may
go down the left-most path forever. Even a finite graph can generate an infinite
tree. One solution to this problem is to impose a cutoff depth on the search.
Although the ideal cutoff is the solution depth d and this value is rarely known in
advance of actually solving the problem. If the chosen cutoff depth is less than d,
the algorithm will fail to find a solution, whereas if the cutoff depth is greater than
d, a large price is paid in execution time, and the first solution found may not be
an optimal one.
• Depth-First Search is not guaranteed to find the solution.
• And there is no guarantee to find a minimal solution, if more than one solution
exists.
Definition
Process
Algorithmic steps
Example
Code
Time Complexity
Advantages
Disadvantages
Dfs presentation

More Related Content

PPTX
Presentation on Breadth First Search (BFS)
PPTX
Depth first search [dfs]
PPT
Karnaugh map
PPTX
Depth-First Search
PPT
Depth First Search ( DFS )
PPTX
Bfs and Dfs
PPTX
Breadth First Search & Depth First Search
DOCX
1 d heat equation
Presentation on Breadth First Search (BFS)
Depth first search [dfs]
Karnaugh map
Depth-First Search
Depth First Search ( DFS )
Bfs and Dfs
Breadth First Search & Depth First Search
1 d heat equation

What's hot (20)

PPTX
DFS and BFS
PPTX
PPTX
Tree Traversal
PPT
Hill climbing
PPT
Iterative deepening search
PPTX
Binary Search Tree
PPTX
Graph traversals in Data Structures
PPTX
Tree traversal techniques
PPTX
Graph coloring using backtracking
PDF
I.ITERATIVE DEEPENING DEPTH FIRST SEARCH(ID-DFS) II.INFORMED SEARCH IN ARTIFI...
PPTX
Problem solving agents
PDF
Quick Sort , Merge Sort , Heap Sort
PPTX
Threaded Binary Tree
PPTX
Graph representation
PPTX
PPT
Fundamentals of data structures
PPTX
Algorithm and pseudocode conventions
PPTX
uninformed search part 1.pptx
PPT
Intermediate code generation (Compiler Design)
PPT
Binary search tree(bst)
DFS and BFS
Tree Traversal
Hill climbing
Iterative deepening search
Binary Search Tree
Graph traversals in Data Structures
Tree traversal techniques
Graph coloring using backtracking
I.ITERATIVE DEEPENING DEPTH FIRST SEARCH(ID-DFS) II.INFORMED SEARCH IN ARTIFI...
Problem solving agents
Quick Sort , Merge Sort , Heap Sort
Threaded Binary Tree
Graph representation
Fundamentals of data structures
Algorithm and pseudocode conventions
uninformed search part 1.pptx
Intermediate code generation (Compiler Design)
Binary search tree(bst)
Ad

Similar to Dfs presentation (20)

PPT
Chapter3 Search
PPT
Ch4: Searching Techniques 6_2018_12_25!05_35_25_PM.ppt
PPTX
AIArtificial intelligence (AI) is a field of computer sciencehsh
PPT
m3-searchAbout AI About AI About AI1.ppt
PPTX
Introduction of Depth First Search with example
PPT
uniformed (also called blind search algo)
PPT
2012wq171-03-UninformedSeknlk ;lm,l;mk;arch.ppt
PPTX
Lecture 08 uninformed search techniques
PPT
AI-search-metodsandeverythingelsenot.ppt
PPTX
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
PDF
dfs-180809142044.pdf
PPTX
RPT_AI_03_PartB_UNINFORMED_FINAL.pptx
PPTX
ARTIFICIAL INTELLIGENCE UNIT 2(2)
PPTX
Lec 15-graph Searching in data structure and lgorithm.pptx
PPTX
4.Module_2_Chaptjvyfgcgfxfdxhgfxchtfer_3.pptx
PPTX
Unit-2 for AIML including type of searches
PPTX
Artificial Intelligence Problem Slaving PPT
PPTX
DOCX
graphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docx
Chapter3 Search
Ch4: Searching Techniques 6_2018_12_25!05_35_25_PM.ppt
AIArtificial intelligence (AI) is a field of computer sciencehsh
m3-searchAbout AI About AI About AI1.ppt
Introduction of Depth First Search with example
uniformed (also called blind search algo)
2012wq171-03-UninformedSeknlk ;lm,l;mk;arch.ppt
Lecture 08 uninformed search techniques
AI-search-metodsandeverythingelsenot.ppt
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
dfs-180809142044.pdf
RPT_AI_03_PartB_UNINFORMED_FINAL.pptx
ARTIFICIAL INTELLIGENCE UNIT 2(2)
Lec 15-graph Searching in data structure and lgorithm.pptx
4.Module_2_Chaptjvyfgcgfxfdxhgfxchtfer_3.pptx
Unit-2 for AIML including type of searches
Artificial Intelligence Problem Slaving PPT
graphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docx
Ad

Recently uploaded (20)

PDF
LDMMIA Reiki Yoga Finals Review Spring Summer
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
A systematic review of self-coping strategies used by university students to ...
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
Lesson notes of climatology university.
PDF
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Classroom Observation Tools for Teachers
PPTX
Cell Structure & Organelles in detailed.
PDF
Practical Manual AGRO-233 Principles and Practices of Natural Farming
PPTX
Orientation - ARALprogram of Deped to the Parents.pptx
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
01-Introduction-to-Information-Management.pdf
LDMMIA Reiki Yoga Finals Review Spring Summer
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
A systematic review of self-coping strategies used by university students to ...
Anesthesia in Laparoscopic Surgery in India
2.FourierTransform-ShortQuestionswithAnswers.pdf
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
Chinmaya Tiranga quiz Grand Finale.pdf
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Lesson notes of climatology university.
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
Final Presentation General Medicine 03-08-2024.pptx
Classroom Observation Tools for Teachers
Cell Structure & Organelles in detailed.
Practical Manual AGRO-233 Principles and Practices of Natural Farming
Orientation - ARALprogram of Deped to the Parents.pptx
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
01-Introduction-to-Information-Management.pdf

Dfs presentation