Posted on

Breadth First Traversal graph vs Breadth First Traversal tree

Breadth First Traversal for a graph is similar to Breadth First Traversal of a tree. 

The only catch here is, unlike trees, graphs may contain cycles, so we may come to the same node again. To avoid processing a node more than once, we use a boolean visited array.
Leave a Reply

Your email address will not be published. Required fields are marked *