Why we need extra for loop to traverse all the vertices, when adding in queue will itself check its edges and go deeper ? and I do not see such extra loop alog other then educative.
Please help.
I got my answer here https://www.youtube.com/watch?v=knbGy2tED-Y
The reason for extra look is for handling a case in which a part of a graph is disconnected, detailed explained in video.
3 Likes