Breadth First Search using Queue | A Helpful Line-by-Line Code Tutorial


The Code can be found at:

Follow me on Instagram @graphoarty as I’m super active on there if you have any follow-up questions!

HELP ME GET TO 10k Subs!

If you learned something new and w – show your boy some love.

I post about the projects I’m working on:
✔ Instagram:
✔ Twitter:
✔ Snapchat: @graphoarty


❌ Do not click this link:

I do not claim to own any of the code explained in the video unless I explicitly mention that I own the code. It is usually inspired by various websites and I have tried to make some of my own changes for the sake of this tutorial.

Send me an email or comment below if you want to be credited.



  1. Your explanation is very good but I feel like your audio is bit distorted and when I listen using headphones it irritates a bit. But anyways thumbs up for the explanation.

  2. Dude, i have exam coming up on this topic and i just watched your video you can't believe how much it helped me. Keep up the good work

  3. Hi Thanks for making this video. I just have one question …
    When the node (0) was popped out from the queue at the step before the you used loop, How cum the control is not getting out of the loop when it encounters break statement even at the first iteration (I mean at matrix (0,0))?

  4. I think you should consider an example which better illustrates BFS. Do note that your BFS behaves like DFS, due to the nature of the graph you chose.


Please enter your comment!
Please enter your name here