In graph theory, breadth-first search (BFS) is a graph search algorithm that begins at the root node and explores all the neighboring nodes. Then for each of those nearest nodes, it explores their unexplored neighbor nodes, and so on, until it finds the goal.

learn more… | top users | synonyms

5
votes
2answers
163 views

Print binary search tree by levels function implementation

I do not like this implementation as is seems too much complicated. My idea was to implement some BFS algorithm variant. Some points to notice: I use one queue. In the begining put the tree ...
3
votes
4answers
4k views

Depth First Search & Breadth First Search implementation

I've implemented DFS and BFS implementations. I want to check if the code is readable, contains any issues, and can be improved. GraphImplementation ...
5
votes
1answer
64 views

BFS implementation that walks a tile-based field

I wrote a BFS implementation that walks a tile-based field. It takes a function that should return true for walkable tiles and false for walls. It also takes the start and end points. It currently ...
4
votes
1answer
572 views

Binary tree level order traversal algoritm

I am trying to solve this Binary tree lever order traversal: ...
4
votes
1answer
117 views

Modified BFS code optimizations

I need some help reviewing this code in terms of making as fast as possible. This is a modified version of BFS that does quite a bit of processing on the side. Use case: I have a large graph ...
2
votes
1answer
139 views

Solve a maze in the form of a 2D array using BFS - Haskell

Suggestions for improving coding style are greatly appreciated. ...
3
votes
0answers
169 views

Solve a maze in the form of a 2D array using BFS

Suggestions for improving coding style are greatly appreciated. ...
3
votes
2answers
242 views

Time Limit Exceeded in BFS maze solver

Here's a problem that I tried solving: Lakshagraha was a house built of lacquer, made by the Kauravas to kill the Pandavas. The Kauravas wanted to burn the house down when the Pandavas were ...
0
votes
1answer
1k views

Breadth-first tree traversal using STL list

I am writing code for breadth-first search of a tree with C++'s STL. Please help as I am new to the STL. ...
6
votes
1answer
247 views

Shortest Path in a Unit Cost DAG BFS in Hadoop

Just got done implementing a shortest path algo of a unit cost DAG BFS in Hadoop and wanting to get anyone's opinion on how I could have done it better. The main issue I see is that I lose the ...
3
votes
1answer
440 views

DFS/BFS implementation Cormen's pseudo code

I like this site and thought if putting this dfs/bfs C++ code for Cormen pseudo code.....please give your comments ...
6
votes
1answer
235 views

BFS for creating a queue without repetitions and with loops in the graph

I have a pipeline with loops of filters and one input filter. The rest are splitters, transform and output. I would like my code to go over the filters and push them into a queue (order is ...
2
votes
1answer
119 views

BFS implementation to find connected components taking too long

This is in continuation to a question I asked here. Given the total number of nodes (employees) and the adjacency list (friendship amongst employees), I need to find all the connected components. ...
1
vote
0answers
144 views

T-SQL BFS center node of undirected graph [closed]

I am trying to answer this question by using a breadth-first search from each node of the graph represented by the tables mapSolarSystems and ...
3
votes
3answers
1k views

Shortest path in a grid between two points

I have this problem where I have to find the shortest path in an NxM grid from point A (always top left) to point B (always bottom right) by only moving right or down. Sounds easy, eh? Well here's the ...
2
votes
1answer
1k views

Breadth- and Depth-first search code

Here is my breadth-first search (bfs) and depth-first search (dfs) code for graph traversal. Please give me some constructive ...
6
votes
1answer
1k views

Improve Graph Adjacency List Implementation and Operations

I am studying graphs and I am trying to make a library in C# for myself and anyone else interested, that is didactic and simple, so I can remember how to solve common problems. I would like to ...
2
votes
2answers
668 views

Code review of Pouring water from code chef using Scala

I had posted this question on Stackoverflow and it seems like code review might be a better venue for my query. My question is as follows: I am trying to solve the pouring water problem from codechef ...
5
votes
2answers
718 views

Pouring water problem

I just began to study Scala (coming from Python I had quite a few problems with types) and I want to know if my first code to solve a real problem is nicely done or if there is some points that need ...