It’s quite easy to find a node in a binary search tree, but, what if we are dealing with unordered tree or graph? In this case the problem become little bit tricky. Because, graph or tree might be very deep and breadth, directed or undirected or even worse it can be cycled. In such cases we have different searching algorithms that can be applied on graph, one of these algorithms is called Breadth-First Search (**BFS**).

The algorithm traverses a tree or graph starting from some node, it can be any node in the graph. On the diagram below node “A” will be the starting node.

Farther, the graph can be divided on levels. First level contains starting node, other levels contains child nodes of previous level. The levels in BFS can be illustrated in following way: Continue reading Breadth-First Search (BFS)