Binary tree: Level Order Traversal

  Рет қаралды 599,840

mycodeschool

mycodeschool

10 жыл бұрын

See complete series on data structures here:
• Data structures
In this lesson, we have discussed level order traversal algorithm for binary tree.
See source code here:
gist.github.com/mycodeschool/...
For practice problems and more, visit: www.mycodeschool.com
Like us on Facebook: / mycodeschool
Follow us on twitter: / mycodeschool

Пікірлер: 316
@slayerq3
@slayerq3 8 жыл бұрын
You are doing god's work, seriously...This is the only place I've learned sorting algorithms, trees, linked lists, everything related to my syllabus. I should be paying you instead of my college :P
@AlexanderMcNulty92
@AlexanderMcNulty92 7 жыл бұрын
Sad but true. His code is so much cleaner than anything in the books.
@nikhilbalwani2285
@nikhilbalwani2285 5 жыл бұрын
LOL. Donate generously to mycodeschool.
@vincentlavello3499
@vincentlavello3499 4 жыл бұрын
I totally agree. Thanks for this. I will be donating - wish I could get my tuition refunded and donate it here.
@adityaojha2701
@adityaojha2701 4 жыл бұрын
Man even 4 years later this is the best playlist on DS.
@abdelrhmanahmed1378
@abdelrhmanahmed1378 3 жыл бұрын
@@adityaojha2701 true its the best in the entire world wide web and even among university prof
@jeppojeps
@jeppojeps 6 жыл бұрын
man, I have a PhD in CS, your work is outstanding, it's a great effort to make things clear and accessible to anyone
@betrp
@betrp 3 жыл бұрын
BTW why are you watching this
@BharathKumarSampath
@BharathKumarSampath 3 жыл бұрын
😂 curious to know
@mohandas3212
@mohandas3212 3 жыл бұрын
@@betrp 😂💯
@DangThinh261
@DangThinh261 3 жыл бұрын
Add friend me 🥲
@jackmiller2518
@jackmiller2518 2 жыл бұрын
just had to tell us about your PhD didnt you
@tweede5555
@tweede5555 3 жыл бұрын
6 years later, and this still helped understand. Concepts are truly timeless!
@seabass7615
@seabass7615 7 күн бұрын
10 years for me now lol
@jonathanlim2269
@jonathanlim2269 9 жыл бұрын
I've grown to be a fan of your videos - they're my first stop for any question or concept I need to clarify on programming!
@mycodeschool
@mycodeschool 9 жыл бұрын
Jonathan Lim Thanks a lot :)
@amateurbeginner7538
@amateurbeginner7538 7 жыл бұрын
why do we need current in this example ? :)
@schizophrenicleo3036
@schizophrenicleo3036 4 жыл бұрын
@@mycodeschool Have you guys moved somewhere? Where is the website? There are not new videos from the past three years as well :(
@sravanthkumarchintalacheru1359
@sravanthkumarchintalacheru1359 4 жыл бұрын
@@schizophrenicleo3036 From the comment sections and the news, I learned that the creator of this channel died in a road accident :( He's famous in programming community as Humble Fool
@schizophrenicleo3036
@schizophrenicleo3036 4 жыл бұрын
@@sravanthkumarchintalacheru1359 Oh , I am sorry. Didn't know that. He was indeed making wonderful videos though.
@chia-juchen8246
@chia-juchen8246 6 жыл бұрын
I remember watching your video in linked list for my data structure assignment as a freshman, now I am already studying CS master in the US and start watching your video again for preparing coding interviews! Sir, you're awesome! very clear explanation and easy to follow!
@Srinivasssssss
@Srinivasssssss 6 ай бұрын
This video is almost 9 years ago, but still this video it is the best explaination for level order traversal...(for me) Thank you so much sir...
@nitinjaiman
@nitinjaiman 10 жыл бұрын
dude you are really good in teaching. i went through almost all your videos now i feel really confident in these topics
@pitchaiahsoma5295
@pitchaiahsoma5295 9 жыл бұрын
You are the best teacher with a perfect tone of gifted voice and providing clear explanations about what is happening in memory. These fundamentals would be stamped into our memory easily. Please keep up the great job extending videos to new topics.
@sr3281
@sr3281 9 жыл бұрын
I always check your videos for a quick, concise and clear explanation of anything I want to learn. Your channels the channel I check for first when I search youtube for tech videos. Thank you very much
@mycodeschool
@mycodeschool 10 жыл бұрын
Poyo Boy - A pointer variable always stores an address. For the definition of Node in this lesson, if I have a pointer to current node in a variable named current, then current will give me the address of that node ,,, current->left will give me address of left child and current->right will give me address of right child. Did you watch previous lessons on tree in this series? They should make things clear for you. Data structures: Introduction to Trees
@truongvanloc8275
@truongvanloc8275 10 жыл бұрын
Do we use stack for other binary tree traversal algorithm: PreOder,InOder,PostOder?
@truongvanloc8275
@truongvanloc8275 10 жыл бұрын
void PreOrder(struct Node *root){ if(root)//If root != NULL { printf("%d ",root->data); PreOrder(root->left); PreOrder(root->right); } }
@ramk9953
@ramk9953 7 жыл бұрын
yes bro we are using stack(implicitly) .but ,it takes place in application memory stack
@sunnysidesounds
@sunnysidesounds 9 жыл бұрын
Excellent, this was extremely helpful to visually see the level order traversal. I have been having trouble with other examples visually seeing what was happening and this cleared it up greatly. Thank you!
@AlexanderMcNulty92
@AlexanderMcNulty92 7 жыл бұрын
Your channel has officially earned my trust. I will recommend anyone interested in basic data structures to come here.
@jamisongriffith6308
@jamisongriffith6308 2 жыл бұрын
Incredibly helpful! The theoretical lesson was excellent. The code walkthrough was hard to follow, but you did such a good job at teaching with diagrams that the walkthrough wasn't necessary.
@jessg7144
@jessg7144 5 жыл бұрын
Truly ... Thank You. I love your visual , they always help me understand the concepts.Clear and understandable. Awesome!
@eddyateye810
@eddyateye810 Жыл бұрын
wow, this guy is huge with explanation... keep it up. have been looking for explanation for this but I think i discovered more than i wanted... bless you guy
@mycodeschool
@mycodeschool 10 жыл бұрын
Next Lesson: - Binary tree traversal: Preorder, Inorder, Postorder
@rohit2761
@rohit2761 8 жыл бұрын
+mycodeschool okay babu
@amateurbeginner7538
@amateurbeginner7538 7 жыл бұрын
GOD bless you , you are the best teacher i have ever seen :) great attitude, clear explanation and organized material :)
@CautiousCrow
@CautiousCrow 8 жыл бұрын
Concise and well explained. You're amazing!
@noumanmalik960
@noumanmalik960 6 жыл бұрын
Sir I cant thank enough ,You made me understand all the concepts and I will promote your channel in whatever way I can. Thank you
@looppp
@looppp 8 жыл бұрын
mycodeschool is the best.
@MJ-zs5jv
@MJ-zs5jv 8 ай бұрын
I plunged into the way you explained. Love it.
@camillesatoshi8393
@camillesatoshi8393 Жыл бұрын
Again, your explanations have the right depth and keeps complete ! Thank you for the great content!🤓
@ritikpatel3286
@ritikpatel3286 5 жыл бұрын
One of the best explanation's out there!
@axelramirezlinarez7449
@axelramirezlinarez7449 5 жыл бұрын
Incredible quality of videos, amazing work!
@austinbvi
@austinbvi 5 жыл бұрын
Can't thank you enough for this playlist!
@Contemelia
@Contemelia 3 жыл бұрын
My prof took 53 minutes. You took 38 seconds. Thanks a lot man :)
@sachinos
@sachinos 8 жыл бұрын
it's big art of having such kind of wonderful explanation.. this remember me all MIT university video...
@jcvandermerwe5311
@jcvandermerwe5311 3 жыл бұрын
I work in C# and this is the first time that I got a clear understanding about Level_Order_Traversing. Brilliant work.
@madanmohan5661
@madanmohan5661 Жыл бұрын
How the Fu*k should I print this, I understand all things that is taught in this video but I don't know how it will print the elements
@lanternarasu6061
@lanternarasu6061 Жыл бұрын
@@madanmohan5661 Don't use curse words in educational videos
@vaibhavtiwari6540
@vaibhavtiwari6540 2 жыл бұрын
Naming the enqueued as discovered nodes and dequeued as visited nodes makes it much more intuitive, thanks.
@MCrown
@MCrown 5 жыл бұрын
You are the best! Thanks for so clear explanation
@honeyshihtzu9675
@honeyshihtzu9675 8 жыл бұрын
Guys u r doing an awesome job.... wish it all happened a decade back...
@goldymarizlunesa8719
@goldymarizlunesa8719 7 жыл бұрын
I love your videos! All very easy to comprehend and understand. Thank you very much.
@jeetsharma1292
@jeetsharma1292 3 жыл бұрын
Awesome ...simple and yet so advanced!
@josnoordzij6802
@josnoordzij6802 3 жыл бұрын
This helped me tremendously. Thank you very much. Great work!
@martini9388
@martini9388 11 ай бұрын
Great video! Very usefull even after 9 years! Code explanation was so good, I had no problems in implementing it into JS and I dont even know any other programming language. Thank you Sir for your work!
@harikrishna-io8sc
@harikrishna-io8sc 5 жыл бұрын
I am shocked by seeing the explanation of code because it is crisp and neat and also easily understandable. Great work sir.Hope you to add Data structures interview questions on trees and linked lists with code
@dawkinsjh
@dawkinsjh 8 жыл бұрын
Super clear explanation of this!
@vishalraghav8982
@vishalraghav8982 7 жыл бұрын
You got a really thorough knowledge, and you are getting way low audience than you deserve. i m trying to tell most of my friends to refer to your channel.
@likithareddy4627
@likithareddy4627 6 жыл бұрын
youre really a kind hearted person. thanks for making such a nice and decent video. i want to like all you videos dude they are really upto mark
@HK-no9wm
@HK-no9wm 6 жыл бұрын
I really wish that u taught at my university. My professor uploaded a bunch of code and told us to go figure it ourselves and that was his genuius idea of teaching.
@MrNiceone99
@MrNiceone99 7 жыл бұрын
Bro you are doing a great job :) I am learning computer science just from videos. Thank you very much.
@laveshchanchawat6983
@laveshchanchawat6983 2 жыл бұрын
until now i seen many videos over the youtube but no one was capable to teach in easy and mannerful way then this,founded the bestest video after learning from many .THAnK you man.
@madanmohan5661
@madanmohan5661 Жыл бұрын
How should I print this, I understand all things that is taught in this video but I don't know how it will print the elements
@anonnona6940
@anonnona6940 Жыл бұрын
Best explanation by far still after 8 years
@amateurbeginner7538
@amateurbeginner7538 7 жыл бұрын
code in C: include include include include define MAX 10 struct BstNode{ int data; struct BstNode* left; struct BstNode* right; }; BstNode* arr[MAX]; int front = -1, rear = -1; bool isEmpty(){ return (front == -1 && rear == -1) ? true : false; } bool isFull(){ return (rear+1)%MAX == front ? true : false; } void enQueue(BstNode* x){ if(isFull()){ printf("queue is full "); return; } if(isEmpty()) front = rear = 0; else rear = (rear+1)%MAX; arr[rear] = x; } void deQueue(){ if(isEmpty()){ printf("queue is empty "); return; } else if(front == rear) front = rear = -1; else front = (front+1)%MAX; } BstNode* getNewNode(int d){ BstNode* newNode = (BstNode*)malloc(sizeof(BstNode)); newNode->data = d; newNode->left = newNode->right = NULL; return newNode; } BstNode* Insert(BstNode* root, int d){ BstNode* newNode = getNewNode(d); if(root == NULL){ root = newNode; } else if(d data){ root->left = Insert(root->left, d); } else root->right = Insert(root->right, d); return root; } void levelOrder(BstNode* root){ if(root == NULL) return; enQueue(root); while(!isEmpty()){ BstNode* current = arr[front]; deQueue(); printf("%d ", current->data); if(current->left != NULL) enQueue(current->left); if(current->right != NULL) enQueue(current->right); } } int main(){ BstNode* root = NULL; root = Insert(root,5); root = Insert(root,10); root = Insert(root,15); root = Insert(root,7); root = Insert(root,3); root = Insert(root,20); root = Insert(root,25); root = Insert(root,21); levelOrder(root); return 0; }
@Cassandra81552
@Cassandra81552 6 ай бұрын
The best explanation ever, thanks a lot!
@sa25078
@sa25078 2 жыл бұрын
Another great video from MyCodeSchool .Thank You for your existence.
@madanmohan5661
@madanmohan5661 Жыл бұрын
How should I print this, I understand all things that is taught in this video but I don't know how it will print the elements
@mursalinhabib1156
@mursalinhabib1156 3 жыл бұрын
These guys are crazy amazing, You guys deserve a Turin prize!
@hhammash
@hhammash 7 жыл бұрын
Great job, your videos are awesome and your presentation method is very clear.
@TangiralaVenkat
@TangiralaVenkat 8 жыл бұрын
Your videos are great sir it clearly explains what is there and helped me a lot Thank you sir Thank you very much
@vithushanjegatheeswaran5317
@vithushanjegatheeswaran5317 7 жыл бұрын
WOW nice tutorial + thank you for the 21:9 format the video fits on my ultrawide screen perfectly
@bilalbashir8361
@bilalbashir8361 7 жыл бұрын
xplaining very lucidly snd clearing the doubts
@memofahood4543
@memofahood4543 10 жыл бұрын
Thank you thank you thank you. Your explanation is so amazing. That helps me a lot
@ajaygunalan1995
@ajaygunalan1995 7 ай бұрын
9 years later, this is still, gold!
@MegaPaloma1988
@MegaPaloma1988 5 жыл бұрын
Thank for the high level quality of the content .. keep doing ;)
@snehill7275
@snehill7275 2 жыл бұрын
& here is your new folwr....concise and well explained. You're amazing! thankyou : )
@jonathanharoun5247
@jonathanharoun5247 3 жыл бұрын
This is actually mind blowing
@nigannayak2139
@nigannayak2139 7 жыл бұрын
videos are really helpful...they helped me a lot....thankyou sir and keep sharing this...
@vijay6877
@vijay6877 4 жыл бұрын
I also love you like many others. after you explain the topic it look so easy and simple.
@AwaraGhumakkad
@AwaraGhumakkad 2 жыл бұрын
Amazing way of explaining :)
@26411bapul
@26411bapul 6 жыл бұрын
This is called best and awesome way of teaching some one. You really deserve 1000 Million likes. :)
@roliverma4483
@roliverma4483 3 жыл бұрын
You make it all so simple :) Thankyou so much
@daboren1547
@daboren1547 4 жыл бұрын
Thank You so Much! The best explanation ever!
@San_Jan_
@San_Jan_ 3 жыл бұрын
Very clean explanation🙂
@elishaalibakhsh7393
@elishaalibakhsh7393 3 жыл бұрын
You saved me one more time. Thanks
@tapanachary2348
@tapanachary2348 4 жыл бұрын
Wow , mind blowing explanation , thank you so much
@premalathak6748
@premalathak6748 9 жыл бұрын
Thank you so much. Great source of learning.
@kunalsoni7681
@kunalsoni7681 4 жыл бұрын
sir seriously this presentation is greatly awesome.. i really learn too much.. thanks 😊😙☺
@dir3mad
@dir3mad 8 жыл бұрын
Amazing work mate
@paragkarguppikar9006
@paragkarguppikar9006 9 жыл бұрын
just awesome.. u r better than all the professors out here :)
@ardhyakumar2539
@ardhyakumar2539 6 жыл бұрын
I bet, anyone cannot find better teaching elsewhere, whether be it paid course or at university :), I am rarely a fan of someone but I've been your and your channel's fan for quite a long time :)
@HeyMr.OO7
@HeyMr.OO7 11 ай бұрын
Legendary.. Simply Legendary 👍🏻
@andreaolexova2621
@andreaolexova2621 9 жыл бұрын
Man you are great! Your videos saved my life! Thanks a lot :)
@ashwinimishra4097
@ashwinimishra4097 5 жыл бұрын
this is the the best way to learn new things .
@GauravSingh-ku5xy
@GauravSingh-ku5xy 2 жыл бұрын
Very well explained.
@danielarodriguez1967
@danielarodriguez1967 2 жыл бұрын
This was very clear, thank you!
@amit5051088
@amit5051088 7 жыл бұрын
Amazing explanation, Superb job #mycodeschool
@rbsupercool
@rbsupercool 10 жыл бұрын
thank you very much again.. mycodeschool rocks.. i'm your biggest fan.. :)
@jasneetsinghanand6761
@jasneetsinghanand6761 3 жыл бұрын
Very easy explanation! Thanks!
@madanmohan5661
@madanmohan5661 Жыл бұрын
How the Fu*k should I print this, I understand all things that is taught in this video but I don't know how it will print the elements
@ivlog4955
@ivlog4955 5 жыл бұрын
Legendary explanation
@CHIchangching
@CHIchangching 10 жыл бұрын
So good..........keep up good things man!
@MiddleClassTalk
@MiddleClassTalk 6 жыл бұрын
you are the best....wish u have uploaded more videos
@freedomformysyria
@freedomformysyria 6 жыл бұрын
thank you شكرا لك وجزاك الله خيرا
@mukeshjangidwwe
@mukeshjangidwwe 8 жыл бұрын
Great Its very helpful for beginners.
@danishuddin9752
@danishuddin9752 2 жыл бұрын
Great great great explanation! Thank you sir!
@madanmohan5661
@madanmohan5661 Жыл бұрын
How the Fu*k should I print this, I understand all things that is taught in this video but I don't know how it will print the elements
@henrikrynauw244
@henrikrynauw244 3 жыл бұрын
Amazing explanantion !
@breakunknown
@breakunknown 2 жыл бұрын
thanks a lot, simple and clear
@kautukraj
@kautukraj 4 жыл бұрын
Very helpful!
@JayasooryanKVpnr
@JayasooryanKVpnr 9 жыл бұрын
love your videos...Thanks a lot!!
@hossamtolba948
@hossamtolba948 4 жыл бұрын
Really your are the best, every time I try to understand a concept you rock it. I hope you rest in peace you did very well
@ishanpand3y
@ishanpand3y 4 жыл бұрын
This man is still alive actually one of the founders of MyCodeSchool Harsha S aka Humblefool has passed away. The man behind this voice, Animesh Nayan, is currently working at Google. You can search his name on Linkedin.
@hossamtolba948
@hossamtolba948 4 жыл бұрын
Really sorry to say, RIP hamblefool. So why Nayan is no longer uploading videos, we miss his videos 😔
@madanmohan5661
@madanmohan5661 Жыл бұрын
How should I print this, I understand all things that is taught in this video but I don't know how it will print the elements
@berna031
@berna031 2 жыл бұрын
thank you for your help
@srichetaruj2590
@srichetaruj2590 8 жыл бұрын
Superb!! thanks for helping :)
@rohithm
@rohithm 9 жыл бұрын
awesome explanation.....!
@AnirudhSinghTomarBME
@AnirudhSinghTomarBME 4 жыл бұрын
Thank you so much for your lectures :))))
@vigneshaigal
@vigneshaigal 9 жыл бұрын
Awesome videos. Thanks a lot
@Hateburn
@Hateburn 2 жыл бұрын
This is amazing.
@guptayash4
@guptayash4 9 жыл бұрын
Well Presented.! :D Thanks for the video.
@rar000000000
@rar000000000 8 жыл бұрын
Very good tutorial. thank you
@nandini-ec5xl
@nandini-ec5xl 6 жыл бұрын
thank you sir,its so helpful
@christopherramos2210
@christopherramos2210 Жыл бұрын
amazing video thank you !!
@honeyshihtzu9675
@honeyshihtzu9675 8 жыл бұрын
I refer ur videos for any doubts ... and seriously u guys should start planning to charge .... :)
@FaizanKhan-qu7is
@FaizanKhan-qu7is 2 жыл бұрын
Very mast explanation...
Binary tree traversal: Preorder, Inorder, Postorder
14:29
mycodeschool
Рет қаралды 952 М.
Delete a node from Binary Search Tree
18:27
mycodeschool
Рет қаралды 1,1 МЛН
LOVE LETTER - POPPY PLAYTIME CHAPTER 3 | GH'S ANIMATION
00:15
I CAN’T BELIEVE I LOST 😱
00:46
Topper Guild
Рет қаралды 81 МЛН
OMG😳 #tiktok #shorts #potapova_blog
00:58
Potapova_blog
Рет қаралды 4,2 МЛН
MultiCloud With DevOps Demo 01 | Introduction To Devops | DevOps Tutorial for Beginners
56:51
Learn Cloud Computing in Telugu and English
Рет қаралды 2
Binary Tree Level Order Traversal - BFS - Leetcode 102
9:36
NeetCode
Рет қаралды 158 М.
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36
Sahil & Sarra
Рет қаралды 610 М.
Erdős-Woods Numbers - Numberphile
14:12
Numberphile
Рет қаралды 117 М.
Inorder Successor in a binary search tree
17:58
mycodeschool
Рет қаралды 358 М.
Merge sort algorithm
18:20
mycodeschool
Рет қаралды 2,2 МЛН
LOVE LETTER - POPPY PLAYTIME CHAPTER 3 | GH'S ANIMATION
00:15