GraphsExplained
0-1 BFS
BFS with a deque: 0-weight edges to the front, 1-weight to the back.
Time
O(V + E)
Extra space
O(V)
Use it for
Graphs whose edges weigh 0 or 1.
BFS with a deque: 0-weight edges to the front, 1-weight to the back.
Time
O(V + E)
Extra space
O(V)
Use it for
Graphs whose edges weigh 0 or 1.