Binary tree: Level Order Traversal

  Рет қаралды 612,559

mycodeschool

mycodeschool

Күн бұрын

Пікірлер: 324
@tweede5555
@tweede5555 3 жыл бұрын
6 years later, and this still helped understand. Concepts are truly timeless!
@seabass7615
@seabass7615 4 ай бұрын
10 years for me now lol
@jervx829
@jervx829 2 ай бұрын
@@seabass7615 how many experience do you have in dev? Me just graduated, but still going back here because too much learning frameworks kinda forgot how this work lmao
@seabass7615
@seabass7615 2 ай бұрын
@@jervx829 Im a sophomore in college for CS right now. I just meant that this 10 year old video still really helped me.
@chia-juchen8246
@chia-juchen8246 7 жыл бұрын
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!
@jeppojeps
@jeppojeps 7 жыл бұрын
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 4 жыл бұрын
BTW why are you watching this
@BharathKumarSampath
@BharathKumarSampath 4 жыл бұрын
😂 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
@Srinivasssssss
@Srinivasssssss 11 ай бұрын
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...
@on_a_grind_rn
@on_a_grind_rn 11 күн бұрын
Its incredible how relevant these videos are even after a decade. Absolute respect to the creator.
@pitchaiahsoma5295
@pitchaiahsoma5295 10 жыл бұрын
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.
@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.
@slayerq3
@slayerq3 9 жыл бұрын
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 6 жыл бұрын
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 4 жыл бұрын
@@adityaojha2701 true its the best in the entire world wide web and even among university prof
@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 2 жыл бұрын
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
@Huehhee7777
@Huehhee7777 Жыл бұрын
@@madanmohan5661 Don't use curse words in educational videos
@ajaygunalan1995
@ajaygunalan1995 11 ай бұрын
9 years later, this is still, gold!
@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 :)
@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
@AlexanderMcNulty92
@AlexanderMcNulty92 7 жыл бұрын
Your channel has officially earned my trust. I will recommend anyone interested in basic data structures to come here.
@vaibhavtiwari6540
@vaibhavtiwari6540 3 жыл бұрын
Naming the enqueued as discovered nodes and dequeued as visited nodes makes it much more intuitive, thanks.
@zondidlaw2195
@zondidlaw2195 Ай бұрын
man i have a PhD in CS and a founder of it, love your videos man, clear explanations
@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
@eddyateye810
@eddyateye810 2 жыл бұрын
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
@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 2 жыл бұрын
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
@AvantikaShukla-b3p
@AvantikaShukla-b3p 2 ай бұрын
Finally found the best explanation of level order traversal
@looppp
@looppp 9 жыл бұрын
mycodeschool is the best.
@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!
@honeyshihtzu9675
@honeyshihtzu9675 8 жыл бұрын
Guys u r doing an awesome job.... wish it all happened a decade back...
@HK-no9wm
@HK-no9wm 7 жыл бұрын
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.
@MJ-zs5jv
@MJ-zs5jv Жыл бұрын
I plunged into the way you explained. Love it.
@jamisongriffith6308
@jamisongriffith6308 3 жыл бұрын
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.
@factwithhunny078
@factwithhunny078 2 жыл бұрын
True
@anonnona6940
@anonnona6940 Жыл бұрын
Best explanation by far still after 8 years
@Contemelia
@Contemelia 3 жыл бұрын
My prof took 53 minutes. You took 38 seconds. Thanks a lot man :)
@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; }
@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
@serenestrolls-d7b
@serenestrolls-d7b 8 жыл бұрын
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.
@sachinos
@sachinos 8 жыл бұрын
it's big art of having such kind of wonderful explanation.. this remember me all MIT university video...
@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
@MaxSharpy
@MaxSharpy Жыл бұрын
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!
@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
@camillesatoshi8393
@camillesatoshi8393 Жыл бұрын
Again, your explanations have the right depth and keeps complete ! Thank you for the great content!🤓
@sa25078
@sa25078 3 жыл бұрын
Another great video from MyCodeSchool .Thank You for your existence.
@madanmohan5661
@madanmohan5661 2 жыл бұрын
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
@TangiralaVenkat
@TangiralaVenkat 9 жыл бұрын
Your videos are great sir it clearly explains what is there and helped me a lot Thank you sir Thank you very much
@saurabh2802
@saurabh2802 Ай бұрын
this is so brilliantly explained
@bilalbashir8361
@bilalbashir8361 7 жыл бұрын
xplaining very lucidly snd clearing the doubts
@DiamondDogGoPewPew
@DiamondDogGoPewPew 6 жыл бұрын
Truly ... Thank You. I love your visual , they always help me understand the concepts.Clear and understandable. Awesome!
@TomLobato
@TomLobato 7 жыл бұрын
great class! tks! in 10:35, the max num of nodes in the deepest level is (n+1)/2, not n/2. Just noticed because I`m using a fixed size queue, so I had to calculate the max.
@akshaypathange3582
@akshaypathange3582 6 жыл бұрын
Tom Lobato he said at least
@vijay6877
@vijay6877 4 жыл бұрын
I also love you like many others. after you explain the topic it look so easy and simple.
@ritikpatel3286
@ritikpatel3286 5 жыл бұрын
One of the best explanation's out there!
@hossamtolba948
@hossamtolba948 5 жыл бұрын
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 5 жыл бұрын
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 5 жыл бұрын
Really sorry to say, RIP hamblefool. So why Nayan is no longer uploading videos, we miss his videos 😔
@madanmohan5661
@madanmohan5661 2 жыл бұрын
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
@jeetsharma1292
@jeetsharma1292 4 жыл бұрын
Awesome ...simple and yet so advanced!
@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 :)
@MrNiceone99
@MrNiceone99 7 жыл бұрын
Bro you are doing a great job :) I am learning computer science just from videos. Thank you very much.
@MJ-zs5jv
@MJ-zs5jv Жыл бұрын
These videos are really great to mayhem the fear of non-linear DS.
@mursalinhabib1156
@mursalinhabib1156 4 жыл бұрын
These guys are crazy amazing, You guys deserve a Turin prize!
@Cassandra81552
@Cassandra81552 10 ай бұрын
The best explanation ever, thanks a lot!
@goldymarizlunesa8719
@goldymarizlunesa8719 7 жыл бұрын
I love your videos! All very easy to comprehend and understand. Thank you very much.
@11m0
@11m0 7 жыл бұрын
Seriously, do you have a patreon or a donation link. I want to show my appreciation for what you've done for me by posting these videos
@kyssl
@kyssl 7 жыл бұрын
Victor Oben he's at Google/Microsoft now
@theFifthMountain123
@theFifthMountain123 6 жыл бұрын
Disable adBlocks for his videos and if possible click on advertiser links.
@JackSparrow-bx8oo
@JackSparrow-bx8oo 4 жыл бұрын
He died in road accident
@anveshreddypinnapareddy3552
@anveshreddypinnapareddy3552 4 жыл бұрын
@@JackSparrow-bx8oo Nah, that's not him. His friend, co-founder of mycodeschool died in a road accident.
@jonathanharoun5247
@jonathanharoun5247 4 жыл бұрын
This is actually mind blowing
@DurgaGuntoju
@DurgaGuntoju 10 жыл бұрын
Nice Explanation. You should explain the Tricky Part here. Output should be level wise. Means, E DJ BEGK ACI H
@ashwinimishra4097
@ashwinimishra4097 6 жыл бұрын
this is the the best way to learn new things .
@josnoordzij6802
@josnoordzij6802 4 жыл бұрын
This helped me tremendously. Thank you very much. Great work!
@26411bapul
@26411bapul 7 жыл бұрын
This is called best and awesome way of teaching some one. You really deserve 1000 Million likes. :)
@nigannayak2139
@nigannayak2139 7 жыл бұрын
videos are really helpful...they helped me a lot....thankyou sir and keep sharing this...
@austinbvi
@austinbvi 5 жыл бұрын
Can't thank you enough for this playlist!
@fury2613
@fury2613 8 жыл бұрын
Probably the only Indian who makes such good videos on programming!
@MCrown
@MCrown 5 жыл бұрын
You are the best! Thanks for so clear explanation
@hhammash
@hhammash 7 жыл бұрын
Great job, your videos are awesome and your presentation method is very clear.
@kunalsoni7681
@kunalsoni7681 5 жыл бұрын
sir seriously this presentation is greatly awesome.. i really learn too much.. thanks 😊😙☺
@dawkinsjh
@dawkinsjh 9 жыл бұрын
Super clear explanation of this!
@snehill7275
@snehill7275 3 жыл бұрын
& here is your new folwr....concise and well explained. You're amazing! thankyou : )
@likithareddy4627
@likithareddy4627 7 жыл бұрын
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
@CautiousCrow
@CautiousCrow 9 жыл бұрын
Concise and well explained. You're amazing!
@PriyanshulGovil
@PriyanshulGovil 3 жыл бұрын
You need to come back, I'm not even kidding!
@zoumzoumzou
@zoumzoumzou 5 жыл бұрын
Great explanations ! it's sad to see that the website is offline :( hopefully you moved on to some other great stuff
@honeyshihtzu9675
@honeyshihtzu9675 8 жыл бұрын
I refer ur videos for any doubts ... and seriously u guys should start planning to charge .... :)
@govindkothari7989
@govindkothari7989 5 жыл бұрын
queue test; void levelorder() { test.push(root); while(!test.empty()) { struct node* temp = test.front(); cout info left) test.push(temp->left); if(temp->right) test.push(temp->right); test.pop(); } } // it will work fine
@paragkarguppikar9006
@paragkarguppikar9006 9 жыл бұрын
just awesome.. u r better than all the professors out here :)
@AwaraGhumakkad
@AwaraGhumakkad 3 жыл бұрын
Amazing way of explaining :)
@Qweertt-y4r
@Qweertt-y4r 2 жыл бұрын
your explanation is on the next level man. but anyone who can help me with the java code of these.
@parthshah6343
@parthshah6343 4 жыл бұрын
Why are we doing queue instead of just queue can anyone please explain?
@elishaalibakhsh7393
@elishaalibakhsh7393 3 жыл бұрын
You saved me one more time. Thanks
@vithushanjegatheeswaran5317
@vithushanjegatheeswaran5317 8 жыл бұрын
WOW nice tutorial + thank you for the 21:9 format the video fits on my ultrawide screen perfectly
@axelramirezlinarez7449
@axelramirezlinarez7449 5 жыл бұрын
Incredible quality of videos, amazing work!
@caseysick2154
@caseysick2154 4 жыл бұрын
Great video and explanation. could just be instead of popping it after pushing. Thank you.
@madanmohan5661
@madanmohan5661 2 жыл бұрын
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
@tapanachary2348
@tapanachary2348 4 жыл бұрын
Wow , mind blowing explanation , thank you so much
@kyzuno5066
@kyzuno5066 Жыл бұрын
God damn it. You are so great at teaching, my tuition should have gone to you instead of my professor.
@simplymade7802
@simplymade7802 6 жыл бұрын
Sir your voice and accent and of course your teaching is amazing...frm where do uh belong sr??
@San_Jan_
@San_Jan_ 3 жыл бұрын
Very clean explanation🙂
@memofahood4543
@memofahood4543 10 жыл бұрын
Thank you thank you thank you. Your explanation is so amazing. That helps me a lot
@kartikxramesh
@kartikxramesh 5 жыл бұрын
Great solution, I paused the video after seeing the question, and tried t solve it myself. Here how i was able to solve it using recursion. void printTree(Node* root){ static int flag = 1; //don't be confused about flag i'm only using it because otherwise every node except the if(!root) //original root node was printing twice return; if(flag){ cout
@tanishkagupta6931
@tanishkagupta6931 4 жыл бұрын
Please make videos on AVL, RB trees, and prominent algos as soon as possible!
@madanmohan5661
@madanmohan5661 2 жыл бұрын
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
@deepeshrathi3408
@deepeshrathi3408 4 жыл бұрын
Travelling in level order with the help of recursion is quite easy than that of while loop
@dallasdominguez2224
@dallasdominguez2224 4 жыл бұрын
Love watching these videos. Theyre like little brain logic puzzles.
@HeyMr.OO7
@HeyMr.OO7 Жыл бұрын
Legendary.. Simply Legendary 👍🏻
@roliverma4483
@roliverma4483 3 жыл бұрын
You make it all so simple :) Thankyou so much
@PiyushJain01
@PiyushJain01 8 жыл бұрын
excellent video of preorder , postorder and inorder . this video cleared my all douts but i will become more better if you also explain algorithm of them. so please provide algo. of them
@harshithvb1
@harshithvb1 7 жыл бұрын
I like your videos very much. Very simple and straight forward explanation. Thank you.
@prats22
@prats22 5 ай бұрын
Watching after 10 years
@DMDRPBHU
@DMDRPBHU 4 жыл бұрын
i rarely comment but you are a legendddddddddddd
@sbond_0077
@sbond_0077 8 жыл бұрын
Thank you is a small word! Keep recording.
@goelshubham46
@goelshubham46 7 жыл бұрын
by the logic u were using,q.pop() should come in the second line of the while loop not in the end.
@rbsupercool
@rbsupercool 10 жыл бұрын
thank you very much again.. mycodeschool rocks.. i'm your biggest fan.. :)
@anirvansen2941
@anirvansen2941 4 жыл бұрын
Python Implementation: def level_order_traversal(self): if not self.root: return -1 else: queue = [] queue.append(self.root) while len(queue) != 0: popped = queue.pop(0) print(popped.data,end=" ") if popped.left: queue.append(popped.left) if popped.right: queue.append(popped.right)
@MegaPaloma1988
@MegaPaloma1988 5 жыл бұрын
Thank for the high level quality of the content .. keep doing ;)
@ivlog4955
@ivlog4955 5 жыл бұрын
Legendary explanation
Binary tree traversal: Preorder, Inorder, Postorder
14:29
mycodeschool
Рет қаралды 963 М.
Delete a node from Binary Search Tree
18:27
mycodeschool
Рет қаралды 1,1 МЛН
Миллионер | 3 - серия
36:09
Million Show
Рет қаралды 2 МЛН
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36
Sahil & Sarra
Рет қаралды 673 М.
I Meet MrBeast To Break The Internet!!
14:00
UR · Cristiano
Рет қаралды 35 МЛН
Binary tree traversal - breadth-first and depth-first strategies
11:54
Premature Optimization
12:39
CodeAesthetic
Рет қаралды 834 М.
Check if a binary tree is binary search tree or not
16:30
mycodeschool
Рет қаралды 380 М.
Binary search tree - Implementation in C/C++
18:36
mycodeschool
Рет қаралды 1,3 МЛН