In the sample test case of this question number of does are given to 4 but graph on checking the edges we find out that there are three nodes only so it printed one node to be absent in the end. But in same sample case for the second test case there is a similar problem but now the missing node printed first. Can you please explain what how we have to print the output in consideration to the above problem?
BFS- shortest path
You have to print the nodes in increasing order .It doesn’t matter whether the node is disconnected or not.