Note that @26:30 I call the "inorder" traversal function inside of the "postorder" traversal function and neglected to change it to postorder. This was a copy-paste error. You can fix it by changing the "inorder" call in postorder to the appropriate postorder call. Sorry for the mistake, and thanks for watching!
@Soccercrazyigboman5 жыл бұрын
How can you go from child back to parent if you don't have a next and previous pointer?
@Soccercrazyigboman5 жыл бұрын
By next and previous I should say if each node doesnt have a pointer pointing to the one above it as well as to the one below it?
@AshwaniKumar-dj6re5 жыл бұрын
@@Soccercrazyigboman he is using recursion
@NicholasSilva13805 жыл бұрын
That changes the expected output from 4-2-5-6-3-7-1- to 4-5-2-6-7-3-1-
@violetkimani31185 жыл бұрын
Hi, would be more efficient to add a function from within the class for adding values to the tree? does it help/ would it be more efficient especially during interviews
@bijayamanandhar38905 жыл бұрын
Thank you for the great tutorial! I am a new developer still looking for a job after graduation from a boot camp. I never had a chance to learn the data-structure, dfs, bfs etc before. Now, it's getting clear to me step by step after watching the videos you posted.
@LucidProgramming5 жыл бұрын
Thank you! If you like my content, I've been working on some projects during the past couple of months. If you would like to stay up-to-date, please consider subscribing to my mail list. Also, if you haven't already, please consider subscribing! I really appreciate the support, and if you want to support the channel, I do have a PayPal link paypal.me/VincentRusso1 for donations that go directly to the creation of content on this channel. I hope that the content I provide there will enhance the videos on my KZbin page. bit.ly/lp_email
@edgarlip24 жыл бұрын
wow - it is awesome !!! i can tell one analogy that helped me a lot : when do i collect the value : • pre-order - when value collected ?: once I am hovering on a node I am collecting it's value. • in-order - when value collected ?: if the node has no left node or the left node is already visited then add this value. • post-order - when value collected ?: once the node has no left nor right or left and right has been already visited then I will collect the value. HTH
@LucidProgramming4 жыл бұрын
Thanks, and yes that's a great way to remember them!
@turjo1194 жыл бұрын
I was stuck for hours trying to understand this, you made it so simple! Thank you so much
@LucidProgramming4 жыл бұрын
Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!
@turjo1194 жыл бұрын
@@LucidProgramming Done and done my good man!
@LucidProgramming4 жыл бұрын
@@turjo119 Cheers, thank you!
@rhythmsaparia87885 жыл бұрын
Your explanation to data structure concepts in python is THE best!
@LucidProgramming5 жыл бұрын
Thank you! If you like my content, I've been working on some projects during the past couple of months. If you would like to stay up-to-date, please consider subscribing to my mail list. Also, if you haven't already, please consider subscribing! I really appreciate the support, and if you want to support the channel, I do have a PayPal link (www.paypal.me/VincentRusso1) for donations that go directly to the creation of content on this channel. I hope that the content I provide there will enhance the videos on my KZbin page. bit.ly/lp_email
@safderaree5 жыл бұрын
Hands down the best explanation, I've struggled for so long trying to get the intuition through my textbook. Thanks!
@LucidProgramming5 жыл бұрын
Thank you! If you like my content, I've been working on some projects during the past couple of months. If you would like to stay up-to-date, please consider subscribing to my mail list. Also, if you haven't already, please consider subscribing! I really appreciate the support. I hope that the content I provide there will enhance the videos on my KZbin page. bit.ly/lp_email
@safderaree5 жыл бұрын
@@LucidProgramming Sure, I've subscribed and signed up for the mailing list. You've made my interviewing process so much smoother.
@LucidProgramming5 жыл бұрын
@@safderaree Awesome, that's really great to hear! :)
@muhammadsalisabdulsalam40165 жыл бұрын
This is the most simplified video tutorial with good examples, the best I have seen so far. I got everything after watching this video only once. A lot of online tutorials are just too ambiguous and really confusing. Lucid you're the best for sure. Thanks a lot
@LucidProgramming5 жыл бұрын
Thank you! If you like my content, I've been working on some projects during the past couple of months. If you would like to stay up-to-date, please consider subscribing to my mail list. Also, if you haven't already, please consider subscribing! I really appreciate the support, and if you want to support the channel, I do have a PayPal link (www.paypal.me/VincentRusso1) for donations that go directly to the creation of content on this channel. I hope that the content I provide there will enhance the videos on my KZbin page. bit.ly/lp_email
@muhammadsalisabdulsalam40165 жыл бұрын
@@LucidProgramming Sure, I'm interested. But how do I subscribe to your mail list please?
@LucidProgramming5 жыл бұрын
@@muhammadsalisabdulsalam4016 Just follow the link here: bit.ly/lp_email :)
@ПавелТаранов-э1ч2 жыл бұрын
Большое спасибо за ваше видео) Это потрясающе, я посмотрел ваш Гайд по связным спискам и теперь я тут. Лучшие видео по этой теме!)
@CodeX-mhs7 ай бұрын
Extremely thankful to you sir.
@LucidProgramming7 ай бұрын
Thank you for the kind words, glad the videos are useful for you!
@CodeX-mhs7 ай бұрын
@@LucidProgramming A very welcome sir. Please keep providing. The growth doesn’t justify ur quality. Keep it up sir.
@wyllerdesousa1710 Жыл бұрын
Nice introduction! Thanks to support the TI community.
@LucidProgramming Жыл бұрын
Cheers!
@hassanfarah35015 жыл бұрын
God bless you Sir. I have been following your tutorials for a while and you are a LEGEND
@LucidProgramming5 жыл бұрын
Thank you! If you like my content, I've been working on some projects during the past couple of months. If you would like to stay up-to-date, please consider subscribing to my mail list. Also, if you haven't already, please consider subscribing! I really appreciate the support, and if you want to support the channel, I do have a PayPal link www.paypal.me/VincentRusso1 for donations that go directly to the creation of content on this channel. I hope that the content I provide there will enhance the videos on my KZbin page. bit.ly/lp_email
@nero99853 жыл бұрын
Thank god I looked at the comments regarding the issue with the post order function, I spent a good 10 mins looking to see if I had the wrong implementation
@LucidProgramming3 жыл бұрын
Glad you caught that, and sorry for the trouble!
@deojeetsarkar20065 жыл бұрын
Your videos deserve more views
@LucidProgramming5 жыл бұрын
Thank you! If you like my content, I've been working on some projects during the past couple of months. If you would like to stay up-to-date, please consider subscribing to my mail list. Also, if you haven't already, please consider subscribing! I really appreciate the support, and if you want to support the channel, I do have a PayPal link (www.paypal.me/VincentRusso1) for donations that go directly to the creation of content on this channel. I hope that the content I provide there will enhance the videos on my KZbin page. bit.ly/lp_email
@enkaibi27565 жыл бұрын
Too excited to sleep now! I finally understand it! Best video on Traversal Algorithms explanation! Consider watching all your python video!
@LucidProgramming5 жыл бұрын
Thank you! If you like my content, I've been working on some projects during the past couple of months. If you would like to stay up-to-date, please consider subscribing to my mail list. Also, if you haven't already, please consider subscribing! I really appreciate the support, and if you want to support the channel, I do have a PayPal link (www.paypal.me/VincentRusso1) for donations that go directly to the creation of content on this channel. I hope that the content I provide there will enhance the videos on my KZbin page. bit.ly/lp_email
@enkaibi27565 жыл бұрын
@@LucidProgramming Just a tiny recommendation, on 17:06, it would be better to use self.root instead of tree .root. Keep going! !!
@LucidProgramming5 жыл бұрын
@@enkaibi2756 Point well taken. Thanks for the comment! :)
@bhuwansharmaa4 жыл бұрын
Best Explanation recursion is bit confusing but following each step through example made it easy... Thanks
@LucidProgramming4 жыл бұрын
Awesome, that's great to hear. Thanks for watching!
@robn86564 жыл бұрын
Just incase there's someone like me out there: I struggled forever to understand how this code and recursive data structures generally worked until I finally understood recursion. Al Sweigart has a great video on recursion but essentially recursive functions use a stack method to determine how the functions are called. the subsequent functions can't be called until the previous one has been removed from the stack. each number being appended to the string is that function being removed from the stack. So, counterintuitively, the string begins with one because it's the LAST METHOD to be cleared from the stack. All, the other methods cycle through the tree first, appending their value to the string. It sounds backwards, I know. I don't even know if I explained it well but you have to understand recursion to understand BST. Watch Sweigart's video.
@LucidProgramming4 жыл бұрын
Cool, thanks for sharing and thanks for watching!
@dmgisi2 жыл бұрын
I appreciate the good video and clear explanation. With a little more editing and attention to detail, it can become more polished and will be excellent.
@LucidProgramming2 жыл бұрын
Thank you! I hope that the videos on this channel keep getting progressively better. Thanks for watching!
@Unknown_22-z8c2 жыл бұрын
very good video for those who want to pick the grasp of binary tree quickly
@LucidProgramming2 жыл бұрын
Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!
@bhaskarbhuyan305 жыл бұрын
Very informative and easy-to-understand tutorial. Thank you for this incredible contribution to the enthusiasts and learners!
@LucidProgramming5 жыл бұрын
Thank you! If you like my content, I've been working on some projects during the past couple of months. If you would like to stay up-to-date, please consider subscribing to my mail list. Also, if you haven't already, please consider subscribing! I really appreciate the support, and if you want to support the channel, I do have a PayPal link (www.paypal.me/VincentRusso1) for donations that go directly to the creation of content on this channel. I hope that the content I provide there will enhance the videos on my KZbin page. bit.ly/lp_email
@jethrotalavera33143 жыл бұрын
Best video I've seen on this topic. Thank you!
@LucidProgramming3 жыл бұрын
Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!
@reccartoon6 жыл бұрын
i really love the way you are explaining all these concepts in very effective manner thanks for this :)
@LucidProgramming6 жыл бұрын
Hi Sarfaraz. Really appreciate that comment, that's very much appreciated! Thank you for watching, and I'm happy to hear this video was effective. Cheers!
@chrisgoehl27454 жыл бұрын
Great Video! Thank you for visualising and really emphasizing on the most basic aspects as this is something which I personally as a Beginner seem to struggle with! Keep up the good work it is really appreciated!
@LucidProgramming4 жыл бұрын
Thanks, Chris! That feedback is really helpful for me and I will try to keep that in mind for future videos. Thanks again for watching and for the comment!
@jayaramakapil52955 жыл бұрын
All Superheroes don't Wear Capes. Some wear Suit too :)
@LucidProgramming5 жыл бұрын
Haha, well I hope the videos are helpful to you. Cheers, and thanks for watching!
@Rich655015 жыл бұрын
Beautiful presentation.
@LucidProgramming5 жыл бұрын
Thank you! If you like my content, I've been working on some projects during the past couple of months. If you would like to stay up-to-date, please consider subscribing to my mail list. Also, if you haven't already, please consider subscribing! I really appreciate the support, and if you want to support the channel, I do have a PayPal link (www.paypal.me/VincentRusso1) for donations that go directly to the creation of content on this channel. I hope that the content I provide there will enhance the videos on my KZbin page. bit.ly/lp_email
@wikhan20024 жыл бұрын
Awesome! Just Awesome! This is where I could navigate to learn such an important thing earlier.
@LucidProgramming4 жыл бұрын
Thank you! :)
@DanielGarcia-uq8yz2 жыл бұрын
I'm only 3 min in but love the explanations. Thanks!
@LucidProgramming2 жыл бұрын
Great to hear, and thank you for the kind words!
@ilanaizelman39933 жыл бұрын
Can't be explained better. Thank you!
@LucidProgramming3 жыл бұрын
Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!
@ilanaizelman39933 жыл бұрын
@@LucidProgramming Done! :) Are you during Mock Interviews? Or know someone who does?
@LucidProgramming3 жыл бұрын
@@ilanaizelman3993 Thank you, Ilan! Your support is very much appreciated! And yes, I do perform mock interviews, coaching, and consulting services for software-based job preparation. If you're interested in setting something up, you're free to reach out to me in the "About" section of my channel and we can coordinate from there if you like. Cheers, and best of luck in your preparation in any case!
@musclecode37714 жыл бұрын
Amazing explanation well worth the time to watch.
@LucidProgramming4 жыл бұрын
Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. I hope to be putting out more similar videos soon!
@TechArtGenius2 ай бұрын
The height and depth concept..I think the depth at the root node is depth 0 and increases by 1 as you go down the tree. And this is the opposite for the heights. But looks like you started counting at 1 instead of 0.
@vishnukumavat74894 жыл бұрын
Thanks for such a cool implementation explanation.
@LucidProgramming4 жыл бұрын
Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. I hope to be putting out more similar videos soon!
@neildutoit51773 жыл бұрын
checking for None using a bool cast is also an anti-pattern. Use "if start is not None" instead.
@gargoth5 жыл бұрын
great video! i would suggest matching the colors of the slides to the colors of the editor, because the sudden switch from dark to light doesn't sit well while watching. thanks!
@LucidProgramming5 жыл бұрын
Thanks for the feedback, that's very helpful to know! Thanks again for watching as well!
@gargoth5 жыл бұрын
no problem dude, i really appreciate your videos!
@LucidProgramming5 жыл бұрын
@@gargoth Cheers, thank you!
@hemesh56633 жыл бұрын
Dude you earned a subscriber and a fan
@LucidProgramming3 жыл бұрын
Thank you, man! Sincerely appreciate the support and love! Cheers!
@kl-je3up2 жыл бұрын
explains it way better than my ds&a textbook lol
@LucidProgramming2 жыл бұрын
Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!
@hussainaqeel73713 жыл бұрын
Great Stuff! Made it very easy to understand! Thanks!
@LucidProgramming3 жыл бұрын
Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!
@hussainaqeel73713 жыл бұрын
@@LucidProgramming sure!
@LucidProgramming3 жыл бұрын
@@hussainaqeel7371 Cheers, thank you!
@alexradu19214 жыл бұрын
I've implemented the traversion with a list version, to be more useful... and also I've modified the print function not to return the list, and just directly print it (because, it's called "print_tree")... class BinaryTree: def __init__(self, root): self.root = Node(root) def print_tree(self, traversal_type): if traversal_type == "preorder": print(self.preorder_list(self.root, [])) elif traversal_type == "inorder": print(self.inorder_list(self.root, [])) elif traversal_type == "postorder": print(self.postorder_list(self.root, [])) def preorder_list(self, start, traversal): ''' Root->Left->Right ''' # start = node update on every recursive call # traversal = list with values of tree in preorder if start: traversal.append(start.value) traversal = self.preorder_list(start.left, traversal) traversal = self.preorder_list(start.right, traversal) return traversal def inorder_list(self, start, traversal): ''' Left->Root->Right ''' if start: traversal = self.inorder_list(start.left, traversal) traversal.append(start.value) traversal = self.inorder_list(start.right, traversal) return traversal def postorder_list(self, start, traversal): ''' Left->Right->Root ''' if start: traversal = self.postorder_list(start.left, traversal) traversal = self.postorder_list(start.right, traversal) traversal.append(start.value) return traversal tree = BinaryTree(1) tree.root.left = Node(2) tree.root.right = Node(3) tree.root.left.left = Node(4) tree.root.left.right = Node(5) tree.root.right.left = Node(6) tree.root.right.right = Node(7) print(tree.preorder_list(tree.root, [])) #you can print the llist directly tree.print_tree("preorder") tree.print_tree("inorder") tree.print_tree("postorder")
@alexradu19214 жыл бұрын
ALSO *Thank you* for this very well explained video on trees using python... If i search the Internet for a Binary Tree in Python I found just very complicated unnecesary syntax.
@LucidProgramming4 жыл бұрын
Cool, thanks for sharing!
@rohith82693 жыл бұрын
great explanation!!
@LucidProgramming3 жыл бұрын
Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!
@khavishbhundoo37926 жыл бұрын
Could you include the link for the presentation as well.It serves as a quick recap.Thanks for the great explanation.
@LucidProgramming6 жыл бұрын
At the moment, those slides are a bit all over the place. However, it would certainly not be an issue to clean them up and post a link in the description of this video. Might take me a while to get around to it, but I'll add it to the list. Thanks for the suggestion and thanks for watching! :)
@gunabalang70344 жыл бұрын
crystal clear
@LucidProgramming4 жыл бұрын
Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!
Just a small question, is it necessary to make whole class BinaryTree just for the root node? or it has something to do with python versions?
@toderickson61062 жыл бұрын
good clarification skills, gave it a like
@LucidProgramming2 жыл бұрын
Very much appreciated--thank you for the support!
@hoangphuoccao1173 жыл бұрын
Great explanations! Thank you very much!!
@LucidProgramming3 жыл бұрын
Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!
@SaltAndVi4 жыл бұрын
phenomenal video, thank you so much!!!
@LucidProgramming4 жыл бұрын
Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!
@cdemr2 жыл бұрын
I am on Pycharm and I am a beginner. I do not understand what you're doing at 18:15. I can force-erase the consol but I can't write inside it.
@gokusaiyan11282 жыл бұрын
What are your vim settings/plugins? I like it
@LucidProgramming2 жыл бұрын
Good question! Much of my configuration is covered here: kzbin.info/www/bejne/rJ3FZKSLnrhlkLs
@drcylon3 жыл бұрын
I think there is a little error in the "print_tree()" function, it shouldn't be "tree.root" it should be "self.root" ! Plus the "postorder" error pointed out in some comments below! Still, it is a great effort. Thanks.
@LucidProgramming3 жыл бұрын
Indeed, thank you for the comment!
@hackytech74944 жыл бұрын
Thank you so much for your explanation it was wonderful. I am having one doubt we haven't coded to go up if we don't have left or right children, then how it goes up programaticaly
@LucidProgramming4 жыл бұрын
Hi Tammay. Thanks for the comment. You might want to check out my recursion playlist if that part is tripping you up. I think it clarifies your confusion. Cheers!
@hackytech74944 жыл бұрын
@@LucidProgramming Ok Thank you so much sir. I will go through that playlist first.
@LucidProgramming4 жыл бұрын
@@hackytech7494 Cheers!
@ramiz35705 жыл бұрын
Amazing explanation, thanks!
@LucidProgramming5 жыл бұрын
Thank you! If you like my content, I've been working on some projects during the past couple of months. If you would like to stay up-to-date, please consider subscribing to my mail list. Also, if you haven't already, please consider subscribing! I really appreciate the support, and if you want to support the channel, I do have a PayPal link (www.paypal.me/VincentRusso1) for donations that go directly to the creation of content on this channel. I hope that the content I provide there will enhance the videos on my KZbin page. bit.ly/lp_email
@theguildedcage6 жыл бұрын
Awesome tutorial! Thanks.
@LucidProgramming6 жыл бұрын
Thank you, Philip! I'm glad you found the tutorial useful! Cheers, and thanks again for watching.
@supamdeepbains51726 жыл бұрын
best explanation on youtube!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@LucidProgramming6 жыл бұрын
Haha, cheers Spamdeep, I really appreciate that :). Happy coding, and thanks for the kind comment!
@ravitanwar95376 жыл бұрын
@@LucidProgramming actually the name is supamdeep not spamdeep
@LucidProgramming6 жыл бұрын
@@ravitanwar9537 Whoops. Must have been my autocorrect? Sorry about that. Thanks for catching, Ravi.
@vnpikachu46276 жыл бұрын
Great work very easy to understand i really appreciate what you are doing to help us
@LucidProgramming6 жыл бұрын
Hey Huru. Thank you very much for that comment. It's really great to hear that these videos have been helpful to you. I really get a lot of enjoyment from doing so as well, so the benefit is mutual! Cheers and thanks again for watching.
@vnpikachu46276 жыл бұрын
Just 30 minutes i go from nothing to understand a lot more about tree could you please make a tutorial about graph and some algorithm about tree ?
@LucidProgramming6 жыл бұрын
Really happy to hear that. Yes, graphs are most certainly coming up soon! Thanks for the suggestion and for the comment!
@olivierbegassat8514 жыл бұрын
Very valuable explanation! Thanks : )
@LucidProgramming4 жыл бұрын
Glad to hear it, and thanks for watching! :)
@olivierbegassat8514 жыл бұрын
@@LucidProgramming The preorder_print function is the sort of thing I would have had a hard time coming up with myself. My naïve attempt would have been to have some list or dictionary of nodes whose left child you've already visited ... instead you simply wrote (amongst other things I'm skipping) traversal = self.preorder_print(start.left, traversal) traversal = self.preorder_print(start.right, traversal) This is really interesting, it's orders of magnitude more elegant and succinct. I wouldn't have come up with it. I would have written some longwinded solution using an extra list or dictionary. Do you know a book or online resource that contains Python implementations of many standard data structures ?
@LucidProgramming4 жыл бұрын
@@olivierbegassat851 Thanks for the comment. Honestly, you can probably just Google for Python data structures and find something reasonably good.
@felipepardosuarez23645 жыл бұрын
Great video. Thank you!
@LucidProgramming5 жыл бұрын
Thank you! If you like my content, I've been working on some projects during the past couple of months. If you would like to stay up-to-date, please consider subscribing to my mail list. Also, if you haven't already, please consider subscribing! I really appreciate the support. I hope that the content I provide there will enhance the videos on my KZbin page. bit.ly/lp_email
@natnaelberhane31412 жыл бұрын
If I'm not mistaken, depth of root node is 0. Root node is at level 0, not 1 :)
@DavidKaplanProgramming6 жыл бұрын
Really good tutorial man! Thanks
@LucidProgramming6 жыл бұрын
Thank you, David, I'm very happy to hear that you enjoyed the tutorial! Cheers.
@HanisaMohamed4 жыл бұрын
Thank you! Explained it very well.
@LucidProgramming4 жыл бұрын
Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!
@VarunKumar-pz5si4 жыл бұрын
Can you explain the recursion in pre-order traversal?
@LucidProgramming4 жыл бұрын
Got a whole playlist on recursion you can check out!
@jingfenghong23124 жыл бұрын
These are awesome videos I have ever seen. I have a question, why don't you use self.root in print_tree() function, but use tree.root?
@LucidProgramming4 жыл бұрын
Thanks! And either convention is fine there. Using self.root would work just as well. Cheers!
@jingfenghong23124 жыл бұрын
@@LucidProgramming Thank you a lot, these videos would definitely help me in my future career interview! I will recommend it to other friends.
@LucidProgramming4 жыл бұрын
@@jingfenghong2312 Thank you, I sincerely appreciate that!
@Me-ex7qg6 жыл бұрын
wish i found your channel earlier. very good
@LucidProgramming6 жыл бұрын
Thanks, TJ. I'm happy you stumbled on it now, and I hope the videos serve you well! Thanks for the comment, and happy coding!
@cryptoTeacherAcademey5 жыл бұрын
Thank you so much for the great tutorial!!
@LucidProgramming5 жыл бұрын
Thank you! If you like my content, I've been working on some projects during the past couple of months. If you would like to stay up-to-date, please consider subscribing to my mail list. Also, if you haven't already, please consider subscribing! I really appreciate the support. I hope that the content I provide there will enhance the videos on my KZbin page. bit.ly/lp_email
@kshitijtewari20255 жыл бұрын
Thanks Sir, what is difference b/w class Node(object): and class Node:
@LucidProgramming5 жыл бұрын
No difference at all!
@amithpandit40435 жыл бұрын
That's right. No difference. According to the link below: in Python 2.7 and older, you need to add the object inside parenthesis. In Python 3 and above, it doesn't make a difference. introtopython.org/classes.html
@abhinavreddy53504 жыл бұрын
@@amithpandit4043 kk tq :)
@ninjaturtle2052 жыл бұрын
in postorder definiition you recursively called inorder. (i think you forgot to update after copy pasting) The answerjjjjj should be 4-5-2-6-7-3-1- excellent video. i understood everything
@LucidProgramming2 жыл бұрын
Thank you! And indeed, I pinned a comment that explains this discrepancy. Good catch in any case!
@ajayprajapati24534 жыл бұрын
Hi..Thank you so much for uploading video with nice explanation..
@LucidProgramming4 жыл бұрын
Cheers! If you found the video helpful, I would definitely appreciate any a like/subscribe/share! Thanks for watching!
@zarioiubogdan11644 жыл бұрын
Hi there! Thank you so much for this! I just discovered your videos and they are so helpful! I was struggling a lot to understand how I could implement and traverse a binary tree. There are countless videos about this but yours really made me understand and gave me hope that with time and practice I could learn these concepts. I saw you have videos on many data structures and I plan to go through all of them and try to understand. Could you please also cover graph implementation and traversal in Python? Thank you again for your help! Wish you the best!
@LucidProgramming4 жыл бұрын
You can feel free to make suggestions on my Patreon page. This would streamline what you want to see and also help to support my channel. www.patreon.com/lucidprogramming
@cudanakiju03 жыл бұрын
@17:04 you type tree.root, shouldn't that be self.root instead?
@bronik72 жыл бұрын
That's what I thought. It's not clear to me how object will know it's instance
@alessiopellegrini5235 ай бұрын
Shouldn't it be self.preorder_print(self.root, " ") in the helper function of the BinaryTree? There is no tree variable in the class and the only way the code is still running correctly is because "tree" happens to be defined outside of class, no?
@nx82215 жыл бұрын
Dude thank you for this!
@LucidProgramming5 жыл бұрын
Thank you! If you like my content, I've been working on some projects during the past couple of months. If you would like to stay up-to-date, please consider subscribing to my mail list. Also, if you haven't already, please consider subscribing! I really appreciate the support, and if you want to support the channel, I do have a PayPal link (www.paypal.me/VincentRusso1) for donations that go directly to the creation of content on this channel. I hope that the content I provide there will enhance the videos on my KZbin page. bit.ly/lp_email
@samkruse62426 жыл бұрын
This is gold
@LucidProgramming6 жыл бұрын
Thanks, Sam! I'm glad that this video was useful to you. Thanks for the comment and for watching! Cheers.
@ГоранДеспотовић Жыл бұрын
Thank you sir!
@LucidProgramming Жыл бұрын
You're very welcome. Thank you for watching!
@ГоранДеспотовић Жыл бұрын
@@LucidProgramming I watched many videos on this subject, yours is spot on! You're a great teacher, thanks again!
@LucidProgramming Жыл бұрын
@@ГоранДеспотовић thank you for the kind words!
@kowyo6 ай бұрын
Thank you for this video
@Mcbridefam201294 жыл бұрын
Hi, thank you so much for the video. I am a little confused still about one thing. When in the preorder traversal, when it comes to a leaf that dosn't have a left or right node, in the code how does it go backwards to the previous node or back to the root?
@LucidProgramming4 жыл бұрын
I would encourage you to check out my playlist on recursion, as it seems you have a gap in understanding how recursive calls are treated.
@someshsangwan37683 жыл бұрын
Thnq sir I am facing a TypeError: Binary tree takes no argument . Tell me about this
@LucidProgramming3 жыл бұрын
You might want to check your code against my GitHub code.
@zewdiherring95282 жыл бұрын
Thanks! Helpful :D
@LucidProgramming2 жыл бұрын
Thank you for watching, and glad to hear that it was helpful!
@vitaliano013 жыл бұрын
Thank you.
@LucidProgramming3 жыл бұрын
Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!
@ishannoying5 жыл бұрын
loved it!
@LucidProgramming5 жыл бұрын
Thank you! If you like my content, I've been working on some projects during the past couple of months. If you would like to stay up-to-date, please consider subscribing to my mail list. Also, if you haven't already, please consider subscribing! I really appreciate the support, and if you want to support the channel, I do have a PayPal link (www.paypal.me/VincentRusso1) for donations that go directly to the creation of content on this channel. I hope that the content I provide there will enhance the videos on my KZbin page. bit.ly/lp_email
@Mankind54902 жыл бұрын
This is fantastic, thank you
@LucidProgramming2 жыл бұрын
Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!
@Mankind54902 жыл бұрын
@@LucidProgramming Already done!
@rohitashpathak2604 жыл бұрын
I started learning python data structure only after watching your videos. Thank you so much. Do you have some projects in python that can we can go through, it will help to build the overall confidence level in coding.
@LucidProgramming4 жыл бұрын
Great to hear. As for projects, I offer tutoring. You can reach out to my email and I can provide you rates and ideas. Cheers!
@rohitashpathak2604 жыл бұрын
LucidProgramming Thanks for your response but if you have some free contents that you can share will be a great help.
@LucidProgramming4 жыл бұрын
@@rohitashpathak260 Due to time constraints, I may have to back away. I can suggest the other content on my KZbin channel, though!
@user-vj3fs4cq9n Жыл бұрын
amazing video
@rhythmsaparia87885 жыл бұрын
I have a doubt, after a while adding nodes by writing tree.root.left.right.left bla bla becomes a cumbersome process, if you could suggest a better and easier way to add nodes than it would be a great help, thanks.
@software-sage5 жыл бұрын
There must always be a way!
@raakobihai29674 жыл бұрын
Thank you soo much for this!
@LucidProgramming4 жыл бұрын
Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!
@vagadellestelle4 жыл бұрын
Excellent explanation, thank you. However, I don't understand why you need a preliminar class "Node"? It wouldn't be sufficient to code the class BinaryTree as simply like: class BinaryTree def __init__(self, root): self.root = root self.left = None self.right = None ?
@LucidProgramming4 жыл бұрын
You could, although it does make sense to split things up as they are fundamentally different objects. It just makes things a bit clearer to understand.
@vagadellestelle4 жыл бұрын
@@LucidProgramming thanks a lot. Will follow your channel for your excellent explanations!
@LucidProgramming4 жыл бұрын
@@vagadellestelle Thank you, I appreciate the support!
@valeriasalas47004 жыл бұрын
Hello, great video. What if I wanted to create a nested list that represented the tree?
@LucidProgramming4 жыл бұрын
Thanks. I'm not sure how to answer the question. It's kind of like asking "how can I loop over the elements in the tree"? Well, you just use a for loop to do so.
@bronik72 жыл бұрын
(17:57) Why in preorder_print (line 4) you passing tree.root? why not self.root? to me it's not clear how Class knows about it's instance? Can you please explain? Thank you
@pythondev26312 жыл бұрын
It is the first time that I come across Instantiate an object of another class without passing it as an argument (Node in BianryTree). Is this a common practise?
@valentynsson59694 жыл бұрын
Legend perfect explanation thank´s I like it.
@LucidProgramming4 жыл бұрын
Thank you! If you like my content, I've been working on some projects during the past couple of months. If you would like to stay up-to-date, please consider subscribing to my mail list. Also, if you haven't already, please consider subscribing! I really appreciate the support, and if you want to support the channel, I do have a PayPal link paypal.me/VincentRusso1 for donations that go directly to the creation of content on this channel. I hope that the content I provide there will enhance the videos on my KZbin page. bit.ly/lp_email
@nivi83194 жыл бұрын
@19:30 i don't know if my doubt sounds silly but I want to know how it is moved upward when there is no left or right subtree I didn't get that please can you explain?? and thank you for this amazing video : )
@LucidProgramming4 жыл бұрын
Thanks, Nivi. I think you might benefit from checking out my recursion playlist as that might clear this up. Hope that helps!
@nivi83194 жыл бұрын
@@LucidProgramming ohh thanks a lot , I'll check that
@LucidProgramming4 жыл бұрын
@@nivi8319 Cheers, let me know if you have questions!
@sarvarjuraev13765 ай бұрын
Thank you very much
@musictrader89904 жыл бұрын
What is the "object" argument you pass when creating class?
@LucidProgramming4 жыл бұрын
It's legacy Python. You can do either class Name: or class Name(object):
@yashpandey3504 жыл бұрын
Sir in each order_print functions how node gets back to head position when its left child or right child becomes None.
@LucidProgramming4 жыл бұрын
Through the recursive call of the function (if I understand the question correctly).
@ajrvasu4 жыл бұрын
@@LucidProgramming Thanks for the great set of videos. My go to playlists. On this one - a bit confused as to how the recursion is getting back to the right child. In the example, after reaching 4, the left child is none. So the recursive function should not enter the loop at all, so how is reading the right child (5)? I get the code intuitively, but am stuck when trying to create the stack line by line to understand the recursion well.
@LucidProgramming4 жыл бұрын
@@ajrvasu I think what might be insightful is to print out the elements as you make the recursive calls. That might make it a bit clearer as to what is happening. Hope that helps!
@ajrvasu4 жыл бұрын
@@LucidProgramming Thanks for the suggestion.
@LucidProgramming4 жыл бұрын
@@ajrvasu No problem, cheers!
@MrAgj2002 жыл бұрын
you say to look at your series of linked lists videos, but then dont link them. and if you do find the linked lists playlist, the first video in the series says its a continuation, so which is the first video, but who know what that is????
@asiacaster36634 жыл бұрын
Im trying to wrap my head around saving the recursive calls in two variables both named traversal in the preorder_print function.. I have spent quite a lot of time learning recursive functions recently (including your videos and others), and thought I understoodd them well for things like binary search and what not, but I still can not picture/map what is going on in my head with those calls in that function, I am getting extremely frustrated right now. Great channel btw, subscribed.
@LucidProgramming4 жыл бұрын
Recursion is one of those things that I think takes a while in wrapping ones head around. I've worked directly with Sam from Byte-by-Byte and he has some really fantastic material on recursion. Specifically, he provides a free e-book on recursion and dynamic programming that has really great visuals of which I haven't really seen elsewhere. I'd recommend giving that a look. And, also, don't get discouraged. Learning these things takes time and practice. Thanks for the support and subscription.
@armans43069 ай бұрын
thanks good tutorial; tho you have a bug which is python's fault to be honest. It has allowed you to do this: return self.preorder_print(tree.root, "") ; it had to be self.root
@arkster006 жыл бұрын
In the postorder_print function, I think you are calling the inorder_print function for the left and right nodes erroneously (copy/paste error).
@LucidProgramming6 жыл бұрын
Yep, you are indeed correct. Looks like I too hastily copied and pasted from the previous traversal. I'll make sure to update my code on Github to reflect the correct traversal algorithm. Nice catch, and thanks for watching!
@arkster006 жыл бұрын
Not a problem. Thank you for posting. All of this is pretty helpful and makes things more clear for the rest of us.
@LucidProgramming6 жыл бұрын
Any time Ahmer, happy to hear that these videos are helpful to others. Cheers and have a nice day!
@theguildedcage6 жыл бұрын
Hello, I looked for traversals on your Github. Couldnt find it. Could you post a link or code correction? Thanks for taking the time to share you knowledge with the masses!
@Iamnoone564 жыл бұрын
Please make videos on graph and please add more questions on trees 😭😭
@LucidProgramming4 жыл бұрын
You can feel free to make suggestions on my Patreon page. This would streamline what you want to see and also help to support my channel. www.patreon.com/lucidprogramming
@raheemwilliams79984 жыл бұрын
how are you able to access attributes from another class without creating an object for it or even using inheritance? plz explain
@LucidProgramming4 жыл бұрын
I think you might need to look into object oriented design on your own. I'm not going to give you a lecture on OOP principles in a KZbin comment.
@piratevv4 жыл бұрын
Hi Vincent, excellent as usual. is it possible to traverse iteratively as well? you got some code for us to see?
@LucidProgramming4 жыл бұрын
Of course, anything you can do recursively you can generally do iteratively. I don't have code for it, but I encourage you to try.
@emadharazi50444 жыл бұрын
Amazing video. Thank you very much. I just have one question. Is it possible to get a string of the tree using the inorder function but with only using one argument instead of two?
@LucidProgramming4 жыл бұрын
Sure, you should be able to do that.
@minaliaggarwal6 жыл бұрын
Hi- I think the code for post-order traversal might be incorrect. Is it supposed to output: [4, 5, 2, 6, 7, 3, 1]? Saw a similar tree in this article with this as the output: www.geeksforgeeks.org/iterative-postorder-traversal-using-stack/
@LucidProgramming6 жыл бұрын
Hi Minali. You are absolutely correct. I checked to make sure the other traversals are correct, and they appear to be. As you say though, there seems to be something incorrect about the post-order traversal. I will be updating the code and also adding a note to the video to ensure others are aware of this. Thank you very much for pointing out my error, I sincerely appreciate this as it improves the quality of the content on this channel. Cheers, and thank you again.
@minaliaggarwal6 жыл бұрын
No problem! Thanks for fixing it!
@LucidProgramming6 жыл бұрын
Ah actually, I believe my issue here was I was calling the "inorder" function inside of the "postorder" function. Another helpful commenter pointed this out and I have since fixed the code. D'oh! :) Thanks again for letting me know, and thanks for your help!
@prakhargurha14274 жыл бұрын
Why is it necessary to define class Node(object) and not class Node() simply as we did in linked list.What's the significance of object
@LucidProgramming4 жыл бұрын
They are equivalent. The former is how things were done in Python 2.7, and the latter is more modern.