BFS (Breadth-First Search) is an algorithm used to traverse or search through a graph or tree. It starts at a source node, visits all the neighboring nodes at the current depth before moving on to nodes at the next depth level. BFS uses a queue (Q) data structure to keep track of the nodes to visit next. The algorithm marks each node as visited to avoid revisiting them and repeats the process until all reachable nodes are explored. It's widely used in finding the shortest path in unweighted graphs and solving various other problems in computer science.
Continue this lesson in the app
Install CourseHive on Android or iOS to keep learning while you move.