








Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An in-depth look at the depth-first search (dfs) algorithm, including its implementation and running time analysis. Visualizations of dfs execution and stack usage, as well as explanations of the main steps in the algorithm and their time complexities.
Typology: Study notes
1 / 14
This page cannot be seen from the preview
Don't miss anything!









Explored nodes (shown in red) Stack
DFS Execution
Explored nodes (shown in red) Stack
Explored nodes (in red) Stack
DFS Execution
Explored nodes (in red) Stack
Explored nodes (in red) Stack
DFS Execution
Explored nodes (in red) Stack
Explored nodes (in red) Stack
DFS Execution
Explored nodes (in red) Stack
Explored nodes (in red) Stack
DFS Execution
Explored nodes (in red) Stack
Explored nodes (in red) Stack
DFS Execution
Explored nodes (in red) Stack
Explored nodes (in red) Stack
DFS Running Time p Running Time of DFS = O(m + n)
DFS Running Time p Main steps in the Algo.
p Count node additions and deletions p Number of additions=Number of deletions
DFS Running Time p Main steps in the Algo.
p Count node additions and deletions p Number of additions=Number of deletions
p Number of times node u gets added
DFS Running Time p Main steps in the Algo.
p Count node additions and deletions p Number of additions=Number of deletions
p Number of times node u gets added
p Total Running time = O(Σu du) = O(m+n)