🤖breadth-first search
🚧 under construction
Last updated
Was this helpful?
🚧 under construction
Last updated
Was this helpful?
Was this helpful?
data structure ⟩ graph ⟩ BFS
Breadth-First Search (BFS)
visits a graph node and explores its neighbors before going on to any of its child nodes. (going wide first before going deep)
an iterative algorithm and makes use of a queue.
// code
// pseudo code
bfs(Graph G, GraphNode root) {
let q be new Queue
root.visited = true // mark root as visited
q.enqueue(root) // add root to the queue
while (q is not empty) {