New answers tagged

0 votes

How to represent BFS and DFS between adjacency matrix and list?

It boils down to the computational model of your BFS or DFS, as well as the sparcity of graphs considered. In an adjacency matrix, you need exactly $|V|^2$ space to store the graph $G$, while in an ...
codeR's user avatar
  • 634
4 votes
Accepted

How to represent BFS and DFS between adjacency matrix and list?

Maybe not exactly what you are looking for, but there is a really cool and natural way to represent BFS with an adjacency matrix. Consider a graph $G = (V, E)$ and its adjacency matrix representation $...
codeing_monkey's user avatar
1 vote
Accepted

DFS (Depth-first search) vs BFS (Breadth-first search) Space Optimizations

Answer to question 1: I am not sure how the version of BFS with iterators would work. But it's also not clear why you would want to do that -- if you are after $O(V)$ space, the original algorithm ...
Tomek Czajka's user avatar

Top 50 recent answers are included