About 2,460,000 results
Open links in new tab
  1. Performing Breadth First Search recursively - Stack Overflow

    Mar 31, 2010 · Let's say you wanted to implement a breadth-first search of a binary tree recursively. How would you go about it? Is it possible using only the call-stack as auxiliary storage?

  2. Printing BFS (Binary Tree) in Level Order with Specific Formatting

    Dec 13, 2009 · Here in my code the function BFS prints the tree level by level, which also fills the data in an int array for printing the tree upside down. (note there is a bit of swapping is used while printing …

  3. Edge classification during Breadth-first search on a directed graph

    Apr 14, 2015 · How do you implement a proper edge classification for a BFS on a directed graph? As you already established, seeing a node for the first time creates a tree edge. The problem with BFS …

  4. Why DFS and not BFS for finding cycle in graphs

    May 29, 2020 · Predominantly DFS is used to find a cycle in graphs and not BFS. Any reasons? Both can find if a node has already been visited while traversing the tree/graph.

  5. I cannot understand BFS Tree Edges in Algorithm Design Manual

    Apr 14, 2021 · I can't understand what this mean The graph edges that do not appear in the breadth-first search tree also have special properties. For undirected graphs, non-tree edges can point only to …

  6. What is the time and space complexity of a breadth first and depth ...

    May 15, 2014 · BFS will have to store at least an entire level of the tree in the queue (sample queue implementation). With a perfect fully balanced binary tree, this would be (n/2 + 1) nodes (the very last …

  7. Equivalence of a graph and a BFS and DFS tree - Stack Overflow

    Apr 27, 2016 · The main difference between dfs and bfs is how they built the tree starting from root.The difference arises when once a vertex is visited,how the adjacent vertices are visited .Let us address …

  8. How to build a BFS tree after running BFS on an undirected graph?

    Jan 30, 2015 · 4 I have an undirected graph and from it, I redrew the same graph but in a tree-like structure (with levels). I know how the Breadth First Search (BFS) algorithm works, but I am not sure …

  9. Is the runtime of BFS and DFS on a binary tree O(N)?

    I realize that runtime of BFS and DFS on a generic graph is O (n+m), where n is number of nodes and m is number of edges, and this is because for each node its adjacency list must be considered. …

  10. How does a Breadth-First Search work when looking for Shortest Path ...

    Technically, Breadth-first search (BFS) by itself does not let you find the shortest path, simply because BFS is not looking for a shortest path: BFS describes a strategy for searching a graph, but it does not …