Loading topic
collections.deque used as a first-in, first-out (FIFO) queue.2 min readcollections.deque, and that you can read Big-O notation. The question here is narrow but matters a lot: at what moment should BFS mark a vertex as visited?3 min readdeque and a visited set, and that you know why vertices are marked visited when they are enqueued. Here we look at the structure BFS leaves behind: each vertex gets a distance, the vertices fall into layers, and the discovery edg3 min readdeque used as a FIFO queue, vertices marked as visited when they are enqueued, and the fact that BFS reaches each vertex first along a path with the fewest edges. Here you will turn that fact into an actual path you can re2 min readdeque used as a FIFO queue, vertices marked visited when they are enqueued, and distances that grow one layer at a time. It also assumes you are comfortable with Python lists and tuples.2 min readdeque used as a FIFO queue, a visited set, and marking each vertex as visited at the moment it is enqueued. It also assumes you know that BFS runs in O(V + E) time.2 min readdeque, why marking vertices when they are enqueued prevents duplicates, and how BFS on a grid treats each open cell as a vertex. Here you will learn how to find each vertex's distance to the nearest of several starting points in a single 3 min readcollections.deque. Here we extend BFS to graphs where every edge costs either 0 or 1.3 min read