Algorithm
Breadth-First Search (BFS) Algorithm:
- Initialize a queue and mark the starting node as visited.
- Enqueue the starting node into the queue.
- While the queue is not empty:
- Dequeue a node from the front of the queue.
- Process the dequeued node (e.g., print or store it).
- For each unvisited adjacent node of the dequeued node:
- Mark the adjacent node as visited.
- Enqueue the adjacent node into the queue.
Example:

Fig. 1: Step-by-Step Process of Breadth-First Search
Note: BFS is particularly useful for finding the shortest path in an unweighted graph and for traversing all nodes level by level.