Binary Tree Level Order Traversal - Drawing The Parallel Between Trees & Graphs

  Рет қаралды 49,173

Back To Back SWE

Back To Back SWE

Күн бұрын

Пікірлер: 133
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
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.
@Azx499
@Azx499 4 жыл бұрын
I'm not finding the code in the description
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
kzbin.info/www/bejne/oqiWgKVsmtZ8pqs
@Azx499
@Azx499 4 жыл бұрын
Back To Back SWE lol
@jenny3416
@jenny3416 4 жыл бұрын
@@Azx499 Same
@danielebanana
@danielebanana 2 жыл бұрын
Where is the code? I can't find in the description
@vasachisenjubean5944
@vasachisenjubean5944 4 жыл бұрын
you are among the few people who keep DSA interesting
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
thanks haha
@matthewmolinar
@matthewmolinar 2 жыл бұрын
fax
@nedwilliams8806
@nedwilliams8806 3 жыл бұрын
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.
@prithazz
@prithazz 4 жыл бұрын
I feel like you are my BFF during interview prep. Otherwise, I would be crying by myself
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
sure if u want
@IChowdhury01
@IChowdhury01 3 жыл бұрын
I'm crying even with these videos. Can't do any tree/graph LC mediums.
@siddhantpathak3811
@siddhantpathak3811 3 жыл бұрын
People get friendzoned even when not asked lol
@ObsessedAwe
@ObsessedAwe 3 жыл бұрын
May God bless this man beyond his wildest dreams.
@yicai7
@yicai7 4 жыл бұрын
The GREATEST explanation about binary tree level order
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
thx
@jpphoopha
@jpphoopha 3 жыл бұрын
This man is an outstanding teacher.
@tannerbarcelos6880
@tannerbarcelos6880 4 жыл бұрын
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
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
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)
@svdfxd
@svdfxd 5 жыл бұрын
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.
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
Workin on it. I wish this could be my full-time job for a little. Too much work ahead.
@matthall8555
@matthall8555 5 жыл бұрын
Well done good sir!!! You drastically reduce the amount of time needed to study these problems!!!
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
haha nice
@rakeshreddyabbireddy8876
@rakeshreddyabbireddy8876 4 жыл бұрын
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
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
lol, I am brain friendly lmao great
@jingjing6813
@jingjing6813 5 жыл бұрын
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.
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
sure, we have a long way to go.
@nurlanikhsanov6531
@nurlanikhsanov6531 2 жыл бұрын
Man, you are an amazing teacher! Please, keep going!
@belzy91
@belzy91 4 жыл бұрын
Really amazing explanation. Your tutorials are invaluable. I really appreciate this. Thank you.
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
thanks
@lsamparkl
@lsamparkl 4 жыл бұрын
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.
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
thanks
@amilaiddamalgoda9916
@amilaiddamalgoda9916 5 жыл бұрын
One of the best explanations by far! keep it up 👍
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
ye
@KPsparks
@KPsparks 4 жыл бұрын
You do sucha great job explaining concepts!
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
sure
@ethanz4928
@ethanz4928 4 жыл бұрын
not seen the code in the description.
@avery2260
@avery2260 2 жыл бұрын
Your videos are amazing and so helpful! Please keep them coming!
@OllytheOzzy
@OllytheOzzy 4 жыл бұрын
Dude you make it all so so so clear and easy to understand. Thankyou so much
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
ye
@arinmis
@arinmis 3 жыл бұрын
Just awesome. You tell those things too clear and it makes this perfect.
@tajrinkashem1416
@tajrinkashem1416 4 жыл бұрын
i just wanna hug you .you are the best man
@jerrick.warren
@jerrick.warren 5 жыл бұрын
My dude.. that was an amazing video. I appreciate you. Thanks.
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
ye
@mehkiheath9551
@mehkiheath9551 4 жыл бұрын
Such a great teacher!
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
thank you!
@bhavishahadiyal7836
@bhavishahadiyal7836 3 жыл бұрын
Brooo you are the best I'll definitely help this channel after cracking my interview
@prashant211087
@prashant211087 5 жыл бұрын
First video with 0 disklies. Great
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
ye
@abdoulbarry8111
@abdoulbarry8111 3 жыл бұрын
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
@MohitSinha4
@MohitSinha4 4 жыл бұрын
Thats an amazing video, it really helped me to understand BFS.
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
excellent
@yuselina8769
@yuselina8769 3 жыл бұрын
Thank you for all your videos!!
@danielzheng7673
@danielzheng7673 3 жыл бұрын
Very good video and easy understanding explanation. Thumb up!
@milanpatel6240
@milanpatel6240 3 жыл бұрын
You are simply awesome. You made it so simple
@chbh3
@chbh3 4 жыл бұрын
lol, thumbnail photo ! this was helpful, ty
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
my b - older me was whack
@sakshamsrivastava6280
@sakshamsrivastava6280 3 жыл бұрын
Thank you for this, helped me visualize it
@NadyaPena-01
@NadyaPena-01 4 жыл бұрын
Thank you so much for this explanation.
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
sure
@kyokokirigiri166
@kyokokirigiri166 3 жыл бұрын
This man is amazing
@MiguelMartinez-xx2zy
@MiguelMartinez-xx2zy 5 жыл бұрын
You have a noble mission sir! thank you for the great video.
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
ye
@carloslazarin
@carloslazarin 2 жыл бұрын
Thank you!! great explanation!
@yathanshtewatia2104
@yathanshtewatia2104 3 жыл бұрын
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
@Shino_Aizawa Жыл бұрын
thank you for a great explanetion
@AhmedAli-jx9ie
@AhmedAli-jx9ie 3 жыл бұрын
there is no code in the description
@sofiullah-iqbal-kiron
@sofiullah-iqbal-kiron 3 жыл бұрын
A Great Teacher. Thanks a lot.
@sanketatmaram
@sanketatmaram 3 жыл бұрын
Great explanation
@jkim5118
@jkim5118 5 жыл бұрын
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?
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
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.
@jkim5118
@jkim5118 5 жыл бұрын
@@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"?
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
@@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.
@anshikagarg7383
@anshikagarg7383 4 жыл бұрын
You help alot Sir,THANKYOU SOO MUCH FOR THE VIDEOS.
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
sure
@extol_entry
@extol_entry 3 жыл бұрын
It seems like you removed the link to the code in the description?
@maneshwarsingh8688
@maneshwarsingh8688 4 жыл бұрын
WHERE IS THE "CODE IN THE DESCRIPTION"? Looks like I'm never able to see it
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
The repository is deprecated - we only maintain backtobackswe.com now.
@maneshwarsingh8688
@maneshwarsingh8688 4 жыл бұрын
@@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 🙏🏽
@fredwooten14
@fredwooten14 5 жыл бұрын
Great work!
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
thanks
@deroytanaka
@deroytanaka 5 жыл бұрын
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
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
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.
@deroytanaka
@deroytanaka 5 жыл бұрын
Back To Back SWE no problem 🤙🏾 I'll just watch all the concepts idk as well
@curiositykeeda8392
@curiositykeeda8392 5 жыл бұрын
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-- } }
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
thanks and I'm not sure there is much I can do to help with your placements. And there is code in the description
@priyatanwar8905
@priyatanwar8905 4 жыл бұрын
@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
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
I want to read and reply but speed replying im sorry I love you
@priyatanwar8905
@priyatanwar8905 4 жыл бұрын
@@BackToBackSWE haha well I luv u 2 and waiting for ur reply :D
@mohammedcardian
@mohammedcardian Жыл бұрын
where's the code ?!
@BackToBackSWE
@BackToBackSWE Жыл бұрын
Hi, the code is maintained on www.backtobackswe.com
@maayan182
@maayan182 5 жыл бұрын
your videos are awesome. thank you :)
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
sure
@dhananjayan281
@dhananjayan281 4 жыл бұрын
You are great man♥️
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
thanks
@pedrolacerda2708
@pedrolacerda2708 5 жыл бұрын
Great video!
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
thanks
@yitingg7942
@yitingg7942 4 жыл бұрын
I don't ever find the code anymore, which makes it hard for me to write it myself even if I understand the explanation.
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
noted - we only maintain code on backtobackswe.com now
@andrewkuhlman1665
@andrewkuhlman1665 Жыл бұрын
I imagine we feel the same way about "conclusions" lol
@harrietread1749
@harrietread1749 3 жыл бұрын
thank you
@alirezaRahmanikhalili
@alirezaRahmanikhalili 5 жыл бұрын
good job man
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
thanks
@ElGalloUltimo
@ElGalloUltimo 5 жыл бұрын
Boom. 256th like. On to the next byte of likes. I feel special 😄
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
nice
@techzoo1
@techzoo1 4 жыл бұрын
I feel like also adding and talking about code rather than just talking about algo would be helpful.
@ameensherif
@ameensherif 2 жыл бұрын
Where is the code for this, I couldn't find it in description.
@BackToBackSWE
@BackToBackSWE 2 жыл бұрын
We maintain the code on backtobackswe.com
@GoatTwinkie
@GoatTwinkie 3 жыл бұрын
holy shit this makes so much sense
@bekaryskuralbay3751
@bekaryskuralbay3751 5 жыл бұрын
Amazing!
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
ye
@smexyapman
@smexyapman 4 жыл бұрын
you are awesome ty
@ViktorTorma
@ViktorTorma 4 жыл бұрын
this is awesome :D
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
thanks
@airysm
@airysm 5 жыл бұрын
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
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
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_Nexus
@Salesforce_Nexus 4 жыл бұрын
awsome!
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
thanks
@nehapai8177
@nehapai8177 4 жыл бұрын
where is the code?
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
The repository is deprecated - we only maintain backtobackswe.com now.
@dhargakolla8982
@dhargakolla8982 3 жыл бұрын
Is the code moved out from this description
@swapnik1000
@swapnik1000 3 жыл бұрын
There is no code in the description 8:09
@danielebanana
@danielebanana 2 жыл бұрын
Where is the code? I can't find in the description
@BackToBackSWE
@BackToBackSWE 2 жыл бұрын
You can check out the code repository on backtobackswe.com/
@mohammad-aminebanaei886
@mohammad-aminebanaei886 2 жыл бұрын
Awesome
@tobioy
@tobioy 4 жыл бұрын
uh, where's the code
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
The repository is deprecated and we only maintain backtobackswe.com now.
@oborofolusho212
@oborofolusho212 5 жыл бұрын
I neeeeed serious help with compiler, do you guys do that!!!!
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
haha I'm not a compiler expert
@digvijayyamagekar4300
@digvijayyamagekar4300 2 жыл бұрын
where is the code man ?
@markohy9samy565
@markohy9samy565 Жыл бұрын
dfds
The Ultimate Sausage Prank! Watch Their Reactions 😂🌭 #Unexpected
00:17
La La Life Shorts
Рет қаралды 8 МЛН
The IMPOSSIBLE Puzzle..
00:55
Stokes Twins
Рет қаралды 182 МЛН
Lowest Common Ancestor Between 2 Binary Tree Nodes (A Recursive Approach)
20:30
Binary tree: Level Order Traversal
11:23
mycodeschool
Рет қаралды 612 М.
Learn Tree traversal in 3 minutes 🧗
3:56
Bro Code
Рет қаралды 123 М.
Binary Tree Level Order Traversal
5:38
Kevin Naughton Jr.
Рет қаралды 83 М.
Today's Console Pick 🔥
0:11
Gleb POV
Рет қаралды 1,4 МЛН
💁‍♂️Зачем infinix это сделала?🤦‍♂️
0:42
Не шарю!
Рет қаралды 1,1 МЛН
Such a gadget should be at hand.
0:17
Super Craft
Рет қаралды 3,4 МЛН
Как подключить магнитолу?
0:51
KS Customs
Рет қаралды 2,3 МЛН
Анимация логотипа для компании MYCOM
0:46
FreelStep Shorts
Рет қаралды 720 М.