## Resolved: Find all paths from source to target in given depth

In this post, we will see how to resolve Find all paths from source to target in given depth Question: I currently use networkx and find paths like this paths = networkx.all_simple_paths(g, source, target, depth) But this return only simple ...

## Resolved: Algorithm for “balanced” breadth-first search

In this post, we will see how to resolve Algorithm for “balanced” breadth-first search Question: I’m looking for references for an algorithm that conducts a breadth-first tree search in a balanced manner that is resilient in a situation where we ...

## Resolved: Good algorithm for finding shortest path for specific vertices

In this post, we will see how to resolve Good algorithm for finding shortest path for specific vertices Question: I’m solving the problem described below and can’t think of a better algorithm than trying every permutation of every vertex of ...

## Solved: What are the practical factors to consider when choosing between Depth-First Search (DFS) and Breadth-First Search (BFS)?

Question: I understand the differences between DFS and BFS, but I’m interested to know what factors to consider when choosing DFS vs BFS. Things like avoiding DFS for very deep trees, etc. Best Answer: That heavily depends on the structure ...

## Resolved: Time Limit Exceed for BFS algorithm

Question: It is leetcode #200, number of islands. My code is It works fine. But when I change the bfs function into It gives me the Time Limit Exceeded error, what could the reasons be? I think these two codes ...

## Resolved: Why can DFS handle a graph with multiple components while BFS cannot?

Question: Consider the standard pseudocode for BFS (modified from CLRS) This version of BFS runs on a starting vertex source and will visit all vertices reachable from source. Yet if G has multiple components, BFS() won’t visit all the vertices ...

## Resolved: Binary Tree BFS without queue

Question: I am working on a solution for https://leetcode.com/problems/binary-tree-level-order-traversal/submissions/. I want to implement level order traversal without using a queue since that solution is quite trivial. I have written the following code, which, in theory should work, but is giving ...

## Resolved: How can I increase my BFS speed when solving the 8-puzzle problem?

Question: I am implementing BFS for a project. I am trying to solve the 8 puzzle game. I tested my BFS implementation on simpler inputs such as the following and it works: Input State: [1, 2, 5, 3, 4, 8, ...

## Resolved: Unsure if this is breadth first or depth first search?

Question: I’m reviewing bfs and dfs concepts and recently wrote this search method for a Trie tree. I believe it is bfs because we’re searching each level starting from the root if the next value exists. I’m not sure what ...

## Resolved: My recursive BFS implemention is not providing the correct answer

Question: Input: My output: [2, 1, 15, 5, 2, 1] Expected output: [2, 1, 21, 5, 2, 1] I am concerned that in the case where my recusion branches out in multiple directions, it isn’t adding all the additional widths ...