Top "Depth-first-search" questions

Depth-first search (DFS) is an algorithm for traversing or searching a tree, tree structure, or graph.

When is it practical to use Depth-First Search (DFS) vs Breadth-First Search (BFS)?

I understand the differences between DFS and BFS, but I'm interested to know when it's more practical to use one …

algorithm graph-algorithm graph-theory depth-first-search breadth-first-search
Breadth First Vs Depth First

When Traversing a Tree/Graph what is the difference between Breadth First and Depth first? Any coding or pseudocode examples …

algorithm depth-first-search breadth-first-search tree-traversal
Explanation of runtimes of BFS and DFS

Why are the running times of BFS and DFS O(V+E), especially when there is a node that has …

data-structures graph time-complexity depth-first-search breadth-first-search
Detecting cycles in a graph using DFS: 2 different approaches and what's the difference

Note that a graph is represented as an adjacency list. I've heard of 2 approaches to find a cycle in a …

graph cycle depth-first-search adjacency-list
Depth-first search (DFS) code in python

Can you please let me know what is incorrect in below DFS code. It's giving correct result AFAIK, but I …

python depth-first-search
Why DFS and not BFS for finding cycle in graphs

Predominantly DFS is used to find a cycle in graphs and not BFS. Any reasons? Both can find if a …

algorithm tree graph-theory depth-first-search breadth-first-search
How to implement depth first search for graph with a non-recursive approach

I have spent lots of time on this issue. However, I can only find solutions with non-recursive methods for a …

algorithm graph depth-first-search non-recursive
How can I remember which data structures are used by DFS and BFS?

I always mix up whether I use a stack or a queue for DFS or BFS. Can someone please provide …

stack queue depth-first-search breadth-first-search
Time complexity of depth-first graph algorithm

I am starting to learn time complexity, and I looked in the examples for the time complexity for some simple …

algorithm time-complexity depth-first-search
Iterative DFS vs Recursive DFS and different elements order

I have written a recursive DFS algorithm to traverse a graph: void Graph<E, N>::DFS(Node n) { …

c++ algorithm graph depth-first-search traversal