Table of Contents: A Quick Message 0:00 - 1:01 The Problem Introduction 1:01 - 1:41 Starting With What We Know? 1:41 - 2:34 How Do We Transition To Level By Level? 2:34 - 2:41 Connecting Trees & Graphs (no pun intended) 2:41 - 3:04 Do You See A Graph Or A Tree? 3:04 - 3:53 Notice That This Is The Same Tree 3:53 - 5:07 Back To The Original Tree 5:07 - 5:50 We Realize Breadth First Search Is Most Natural 5:50 - 6:25 What Do We Use For Breadth First Search 6:25 - 7:22 Walking Through The Breadth First Search 7:22 - 11:22 The Breadth First Search Is Finished 11:22 - 12:03 Wrap Up 12:03 - 12:36 I Forgot Complexities -> Let n be the # of nodes in the binary tree. Time complexity is O(n) since we process n nodes and perform O(1) work per node processed. Space complexity is O(n) if we put all nodes in an array of arrays (each level gets its own array). Space is also O(n) if the output is not included since the upper bound on the number of items in the queue at any one moment in time will be a fractional component of n. The fractional constant disappears and yields O(n) space. Space scales in a linear fashion with the input size. The code for this problem is in the description. Fully commented for teaching purposes.
@Azx4994 жыл бұрын
I'm not finding the code in the description
@BackToBackSWE4 жыл бұрын
kzbin.info/www/bejne/oqiWgKVsmtZ8pqs
@Azx4994 жыл бұрын
Back To Back SWE lol
@jenny34164 жыл бұрын
@@Azx499 Same
@danielebanana2 жыл бұрын
Where is the code? I can't find in the description
@vasachisenjubean59444 жыл бұрын
you are among the few people who keep DSA interesting
@BackToBackSWE4 жыл бұрын
thanks haha
@matthewmolinar2 жыл бұрын
fax
@nedwilliams88063 жыл бұрын
For me, it clicks. Recursion, BFS, Binary Structures. They're all just clicking thanks to you. Your style of working it out step by step is exactly what I do at home, I have a couple of white boards as well. But your way of looking at these problems has really solidified my understanding. Hats off, sir.
@prithazz4 жыл бұрын
I feel like you are my BFF during interview prep. Otherwise, I would be crying by myself
@BackToBackSWE4 жыл бұрын
sure if u want
@IChowdhury013 жыл бұрын
I'm crying even with these videos. Can't do any tree/graph LC mediums.
@siddhantpathak38113 жыл бұрын
People get friendzoned even when not asked lol
@ObsessedAwe3 жыл бұрын
May God bless this man beyond his wildest dreams.
@yicai74 жыл бұрын
The GREATEST explanation about binary tree level order
@BackToBackSWE4 жыл бұрын
thx
@jpphoopha3 жыл бұрын
This man is an outstanding teacher.
@tannerbarcelos68804 жыл бұрын
I have a interview at SAP next Wednesday. It’s for their new grad talent program. I applied and did an assessment for frontend, and got through that and the first interview. However now it’s technical. I’m not really sure if it’s gonna be related to frontend and such or just basic SWE interview stuff. That said, for a new grad type of role, typically what should someone like me, interviewing for such a role AND never interviewing before, be focusing on? Thank you so much brother. You explained this algorithm amazingly. I see tons of problems requiring BFS / Level Order stuff
@BackToBackSWE4 жыл бұрын
I don't think I'm well positioned to answer this, you should as others who interviewed (if you can get a hold of them)
@svdfxd5 жыл бұрын
As usual, great video. Like the way you explain things by a little revision of topics already learnt e.g. queues used for BFS, stacks used for DFS etc. Keep making these awesome videos to cover all the interview related topics/ questions.
@BackToBackSWE5 жыл бұрын
Workin on it. I wish this could be my full-time job for a little. Too much work ahead.
@matthall85555 жыл бұрын
Well done good sir!!! You drastically reduce the amount of time needed to study these problems!!!
@BackToBackSWE5 жыл бұрын
haha nice
@rakeshreddyabbireddy88764 жыл бұрын
Your teaching is like, hey I don't teach coding but force your brain to code on your own after this lesson. Really you are brain friendly. I think in future you are going to make many new concepts on this channel
@BackToBackSWE4 жыл бұрын
lol, I am brain friendly lmao great
@jingjing68135 жыл бұрын
Thank you so much for this content. I like the way that you explain logic clearly. I appreciate your time to do this. Thanks Ben.
@BackToBackSWE5 жыл бұрын
sure, we have a long way to go.
@nurlanikhsanov65312 жыл бұрын
Man, you are an amazing teacher! Please, keep going!
@belzy914 жыл бұрын
Really amazing explanation. Your tutorials are invaluable. I really appreciate this. Thank you.
@BackToBackSWE4 жыл бұрын
thanks
@lsamparkl4 жыл бұрын
this is so insightful other videos are just plainly teaching how the algorithm works. I also like how you derived at that solution. Ideation is such an important skill to improve upon. I feel like no one does that when explaining the solution.
@BackToBackSWE4 жыл бұрын
thanks
@amilaiddamalgoda99165 жыл бұрын
One of the best explanations by far! keep it up 👍
@BackToBackSWE5 жыл бұрын
ye
@KPsparks4 жыл бұрын
You do sucha great job explaining concepts!
@BackToBackSWE4 жыл бұрын
sure
@ethanz49284 жыл бұрын
not seen the code in the description.
@avery22602 жыл бұрын
Your videos are amazing and so helpful! Please keep them coming!
@OllytheOzzy4 жыл бұрын
Dude you make it all so so so clear and easy to understand. Thankyou so much
@BackToBackSWE4 жыл бұрын
ye
@arinmis3 жыл бұрын
Just awesome. You tell those things too clear and it makes this perfect.
@tajrinkashem14164 жыл бұрын
i just wanna hug you .you are the best man
@jerrick.warren5 жыл бұрын
My dude.. that was an amazing video. I appreciate you. Thanks.
@BackToBackSWE5 жыл бұрын
ye
@mehkiheath95514 жыл бұрын
Such a great teacher!
@BackToBackSWE4 жыл бұрын
thank you!
@bhavishahadiyal78363 жыл бұрын
Brooo you are the best I'll definitely help this channel after cracking my interview
@prashant2110875 жыл бұрын
First video with 0 disklies. Great
@BackToBackSWE5 жыл бұрын
ye
@abdoulbarry81113 жыл бұрын
Dude should be paid $millions to teach Data Structures!! idk which college gonna discover this man first omg i Wish you were my professor haha
@MohitSinha44 жыл бұрын
Thats an amazing video, it really helped me to understand BFS.
@BackToBackSWE4 жыл бұрын
excellent
@yuselina87693 жыл бұрын
Thank you for all your videos!!
@danielzheng76733 жыл бұрын
Very good video and easy understanding explanation. Thumb up!
@milanpatel62403 жыл бұрын
You are simply awesome. You made it so simple
@chbh34 жыл бұрын
lol, thumbnail photo ! this was helpful, ty
@BackToBackSWE4 жыл бұрын
my b - older me was whack
@sakshamsrivastava62803 жыл бұрын
Thank you for this, helped me visualize it
@NadyaPena-014 жыл бұрын
Thank you so much for this explanation.
@BackToBackSWE4 жыл бұрын
sure
@kyokokirigiri1663 жыл бұрын
This man is amazing
@MiguelMartinez-xx2zy5 жыл бұрын
You have a noble mission sir! thank you for the great video.
@BackToBackSWE5 жыл бұрын
ye
@carloslazarin2 жыл бұрын
Thank you!! great explanation!
@yathanshtewatia21043 жыл бұрын
I did this exact same thing when I wanted to print out a visual representation of a BST. If i would have watched this video it would not have taken as long as it did figuring this out myself
@Shino_Aizawa Жыл бұрын
thank you for a great explanetion
@AhmedAli-jx9ie3 жыл бұрын
there is no code in the description
@sofiullah-iqbal-kiron3 жыл бұрын
A Great Teacher. Thanks a lot.
@sanketatmaram3 жыл бұрын
Great explanation
@jkim51185 жыл бұрын
These videos are awesome. It seems like knowing the patterns and having the toolsets to solve any kind of problem is important (as you always mention). When was the moment that you had the feeling that you had all these toolsets to apply to any kind of problem?
@BackToBackSWE5 жыл бұрын
I still don't think I have "all [these] toolsets" but I guess it is when you immediately know what type of problem a problem is. Noticing dynamic programming immediately. Noticing a BFS quickly. Knowing if the solution can be done with 2 pointers in O(n) time. I'm really not THAT good...I'm ok...but yeah.
@jkim51185 жыл бұрын
@@BackToBackSWE Nice. I am still struggling with many questions, but at least I know how to approach it. What is the next step after "Knowing which toolset to use"?
@BackToBackSWE5 жыл бұрын
@@jkim5118 Just having done a lot of questions so that approaches come to mind. It is really all about experience. Intuitions can only go so far.
@anshikagarg73834 жыл бұрын
You help alot Sir,THANKYOU SOO MUCH FOR THE VIDEOS.
@BackToBackSWE4 жыл бұрын
sure
@extol_entry3 жыл бұрын
It seems like you removed the link to the code in the description?
@maneshwarsingh86884 жыл бұрын
WHERE IS THE "CODE IN THE DESCRIPTION"? Looks like I'm never able to see it
@BackToBackSWE4 жыл бұрын
The repository is deprecated - we only maintain backtobackswe.com now.
@maneshwarsingh86884 жыл бұрын
@@BackToBackSWE I'd really appreciate if you give the codes to people who really need it for free. Great job explaining all the tough algos 🙏🏽
@fredwooten145 жыл бұрын
Great work!
@BackToBackSWE5 жыл бұрын
thanks
@deroytanaka5 жыл бұрын
Hey first time viewer, so far I'm liking the content do you have a playlist that has the videos in like sequential order. like the concepts will build off the previous video. thanks
@BackToBackSWE5 жыл бұрын
Hey. I wish I did. I mean, I just do whatever questions I find immediately interesting or pull from a question list I have. I have channel playlists but I ran out of those, I can't make anymore.
@deroytanaka5 жыл бұрын
Back To Back SWE no problem 🤙🏾 I'll just watch all the concepts idk as well
@curiositykeeda83925 жыл бұрын
hey man! Firstly I would like to say that, I am a great admirer of ur work ...u r really doing something which matters a lot. I would like to know that if there is any Email id where I can drop u the mails, actually my placements r coming ...it will be starting from July ...so I am kinda a nervous , I am watching ur videos daily and i am learning alot...i will really appreciate if u can guide me what to do.. and lastly... Is this the pseudo code for the level order traversal is correct?? while(queue is NotNULL) { p =sizeof(queue); while(p!=0) { print(front) enqueue(front->left) enqueue(front->right) dequeue(front) p-- } }
@BackToBackSWE5 жыл бұрын
thanks and I'm not sure there is much I can do to help with your placements. And there is code in the description
@priyatanwar89054 жыл бұрын
@Back To Back SWE - Awesome video !! I have one question, you mentioned in the description that the space complexity without output is also o(n), The fractional constant disappears and the asymptotic behavior is linear. We can't bound the max space in the queue to the widest level because when we process the widest level...if there is a level below it we will have all the nodes from the widest level PLUS what we are adding into the queue as we process each node in the level (we remove 1 node and can add 2 children which will push us past the size of the widest level initially). My question is, will it always be slightly less than O(n) as never we will have all nodes stored in level and in queue? Could you please elaborate further
@BackToBackSWE4 жыл бұрын
I want to read and reply but speed replying im sorry I love you
@priyatanwar89054 жыл бұрын
@@BackToBackSWE haha well I luv u 2 and waiting for ur reply :D
@mohammedcardian Жыл бұрын
where's the code ?!
@BackToBackSWE Жыл бұрын
Hi, the code is maintained on www.backtobackswe.com
@maayan1825 жыл бұрын
your videos are awesome. thank you :)
@BackToBackSWE5 жыл бұрын
sure
@dhananjayan2814 жыл бұрын
You are great man♥️
@BackToBackSWE4 жыл бұрын
thanks
@pedrolacerda27085 жыл бұрын
Great video!
@BackToBackSWE5 жыл бұрын
thanks
@yitingg79424 жыл бұрын
I don't ever find the code anymore, which makes it hard for me to write it myself even if I understand the explanation.
@BackToBackSWE4 жыл бұрын
noted - we only maintain code on backtobackswe.com now
@andrewkuhlman1665 Жыл бұрын
I imagine we feel the same way about "conclusions" lol
@harrietread17493 жыл бұрын
thank you
@alirezaRahmanikhalili5 жыл бұрын
good job man
@BackToBackSWE5 жыл бұрын
thanks
@ElGalloUltimo5 жыл бұрын
Boom. 256th like. On to the next byte of likes. I feel special 😄
@BackToBackSWE5 жыл бұрын
nice
@techzoo14 жыл бұрын
I feel like also adding and talking about code rather than just talking about algo would be helpful.
@ameensherif2 жыл бұрын
Where is the code for this, I couldn't find it in description.
@BackToBackSWE2 жыл бұрын
We maintain the code on backtobackswe.com
@GoatTwinkie3 жыл бұрын
holy shit this makes so much sense
@bekaryskuralbay37515 жыл бұрын
Amazing!
@BackToBackSWE5 жыл бұрын
ye
@smexyapman4 жыл бұрын
you are awesome ty
@ViktorTorma4 жыл бұрын
this is awesome :D
@BackToBackSWE4 жыл бұрын
thanks
@airysm5 жыл бұрын
Hey, I was wondering if you’re ever going to go back to the format of also explaining the code in the video kinda like the N Queens video? If not then it’s cool lol Also I’m watching this video with earphones and I just wanted to give a heads up that for the audio you could hear a low echo and also a low static noice as well from some feedback the mic is picking up
@BackToBackSWE5 жыл бұрын
Yeah, I don't think I am ever since I set the GitHub up. And also, yes I know about the static, I messed up the levels. I am still learning how to use the microphone. For this video I didn't get the mic close enough to my mouth (it was mounted to the camera). I was lazy and didn't use my boom kit. Check out today's video, I made the sound better I think.
@Salesforce_Nexus4 жыл бұрын
awsome!
@BackToBackSWE4 жыл бұрын
thanks
@nehapai81774 жыл бұрын
where is the code?
@BackToBackSWE4 жыл бұрын
The repository is deprecated - we only maintain backtobackswe.com now.
@dhargakolla89823 жыл бұрын
Is the code moved out from this description
@swapnik10003 жыл бұрын
There is no code in the description 8:09
@danielebanana2 жыл бұрын
Where is the code? I can't find in the description
@BackToBackSWE2 жыл бұрын
You can check out the code repository on backtobackswe.com/
@mohammad-aminebanaei8862 жыл бұрын
Awesome
@tobioy4 жыл бұрын
uh, where's the code
@BackToBackSWE4 жыл бұрын
The repository is deprecated and we only maintain backtobackswe.com now.
@oborofolusho2125 жыл бұрын
I neeeeed serious help with compiler, do you guys do that!!!!