We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent dd69d42 commit 60cd296Copy full SHA for 60cd296
Graphs/graphs_dfs.go
@@ -20,6 +20,10 @@
20
The time complexity of the DFS algorithm is O(V + E), where V is the number of vertices (nodes) and E is the number of
21
edges in the graph. This is because the algorithm visits every vertex and every edge once.
22
23
+ The space complexity of DFS depends on the maximum depth of the recursion stack. In the worst case, where the tree or
24
+ graph is completely unbalanced, the recursion stack can reach a depth of O(n), where n is the number of nodes in the graph.
25
+ Therefore, the space complexity of DFS is O(n).
26
+
27
*/
28
package main
29
0 commit comments