The code is not consistent with the example graph

The output of the BFS code is coming 0,1,2,3,4,5 while in the example, the output of BFS was 0,1,3,2,4,5. Why this discrepancy? It is confusing.

Hey @shshwt.khr have you coded it yourself ? If yes then share your code as in bfs, it’s a level order print. So , 2 can’t come before 1 or 3 as it’s on the 3rd level, whereas 1 & 3 are at 2nd level.

the code and the output (0,1,2,3,4,5) are in the video itself

if that is the case, then why the output in the video coming as 0,1,2,3,4,5?

In main function, bhaiya forgot to add a branch 0-3 see it at 11:00 time stamp. Due to which what is it creating is that
0
1
2
3
4
5
Level by level.

oh yes. so the problem was in the input then.

Yo … now I am marking this doubt as resolved.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.