0

Consider the following graph
image of directed graph

I was asked to list the nodes of the graph in breath-first traversal, starting from node 0.

My result is as follow
Breadth First Search for Graph

I'm not sure about the 2 node. What do I do with nodes that connects like this to a graph and is my answer correct? If not, what is the correct answer.

Thank you.

  • 1
    Yep... your answer is correct (yet not unique). – David G. Stork May 31 '20 at 00:03
  • @ David G. Stork, so if there's more than 1 nodes like node 2, do I just execute the same algorithm going in alphabetical order. For instance, if there was another node, node 7, that connects (points to) to node 2 will the answer then be 0 1 4 3 5 6 2 7? – Clint Theron May 31 '20 at 00:16

0 Answers0