Explain breadth-first search (BFS)
Breadth-First Search (BFS) is an algorithm that explores a graph or tree level by level, using a queue to manage nodes. It is particularly effective for finding the shortest path in unweighted graphs and for tasks such as connected component identification and level order traversal in trees. Its time complexity is , and it uses space.