Breadth-First Search uses a queue to explore nodes level by level:
Start: enqueue the source node
Loop: dequeue front, process it, enqueue unvisited neighbors
Stop: when queue is empty or target found This guarantees you visit all nodes at distance before any node at distance . That's why BFS finds shortest paths in unweighted graphs. You won't go deep into BFS here. There's a Graph Theory roadmap for that. But know that queues power BFS.